<!doctype html><html lang="en">
 <head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <title>Service Workers 1</title>
  <link href="https://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css">
<style data-fill-with="stylesheet">/******************************************************************************
 *                   Style sheet for the W3C specifications                   *
 *
 * Special classes handled by this style sheet include:
 *
 * Indices
 *   - .toc for the Table of Contents (<ol class="toc">)
 *     + <span class="secno"> for the section numbers
 *   - #toc for the Table of Contents (<nav id="toc">)
 *   - ul.index for Indices (<a href="#ref">term</a><span>, in §N.M</span>)
 *   - table.index for Index Tables (e.g. for properties or elements)
 *
 * Structural Markup
 *   - table.data for general data tables
 *     -> use 'scope' attribute, <colgroup>, <thead>, and <tbody> for best results !
 *     -> use <table class='complex data'> for extra-complex tables
 *     -> use <td class='long'> for paragraph-length cell content
 *     -> use <td class='pre'> when manual line breaks/indentation would help readability
 *   - dl.switch for switch statements
 *   - ol.algorithm for algorithms (helps to visualize nesting)
 *   - .figure and .caption (HTML4) and figure and figcaption (HTML5)
 *     -> .sidefigure for right-floated figures
 *   - ins/del
 *
 * Code
 *   - pre and code
 *
 * Special Sections
 *   - .note       for informative notes             (div, p, span, aside, details)
 *   - .example    for informative examples          (div, p, pre, span)
 *   - .issue      for issues                        (div, p, span)
 *   - .assertion  for assertions                    (div, p, span)
 *   - .advisement for loud normative statements     (div, p, strong)
 *   - .annoying-warning for spec obsoletion notices (div, aside, details)
 *
 * Definition Boxes
 *   - pre.def   for WebIDL definitions
 *   - table.def for tables that define other entities (e.g. CSS properties)
 *   - dl.def    for definition lists that define other entitles (e.g. HTML elements)
 *
 * Numbering
 *   - .secno for section numbers in .toc and headings (<span class='secno'>3.2</span>)
 *   - .marker for source-inserted example/figure/issue numbers (<span class='marker'>Issue 4</span>)
 *   - ::before styled for CSS-generated issue/example/figure numbers:
 *     -> Documents wishing to use this only need to add
 *        figcaption::before,
 *        .caption::before { content: "Figure "  counter(figure) " ";  }
 *        .example::before { content: "Example " counter(example) " "; }
 *        .issue::before   { content: "Issue "   counter(issue) " ";   }
 *
 * Header Stuff (ignore, just don't conflict with these classes)
 *   - .head for the header
 *   - .copyright for the copyright
 *
 * Miscellaneous
 *   - .overlarge for things that should be as wide as possible, even if
 *     that overflows the body text area. This can be used on an item or
 *     on its container, depending on the effect desired.
 *     Note that this styling basically doesn't help at all when printing,
 *     since A4 paper isn't much wider than the max-width here.
 *     It's better to design things to fit into a narrower measure if possible.
 *   - js-added ToC jump links (see fixup.js)
 *
 ******************************************************************************/

/******************************************************************************/
/*                                   Body                                     */
/******************************************************************************/

	body {
		counter-reset: example figure issue;

		/* Layout */
		max-width: 50em;               /* limit line length to 50em for readability   */
		margin: 0 auto;                /* center text within page                     */
		padding: 1.6em 1.5em 2em 50px; /* assume 16px font size for downlevel clients */
		padding: 1.6em 1.5em 2em calc(26px + 1.5em); /* leave space for status flag     */

		/* Typography */
		line-height: 1.5;
		font-family: sans-serif;
		widows: 2;
		orphans: 2;
		word-wrap: break-word;
		overflow-wrap: break-word;
		hyphens: auto;

		/* Colors */
		color: black;
		background: white top left fixed no-repeat;
		background-size: 25px auto;
	}


/******************************************************************************/
/*                         Front Matter & Navigation                          */
/******************************************************************************/

/** Header ********************************************************************/

	div.head { margin-bottom: 1em }
	div.head hr { border-style: solid; }

	div.head h1 {
		font-weight: bold;
		margin: 0 0 .1em;
		font-size: 220%;
	}

	div.head h2 { margin-bottom: 1.5em;}

/** W3C Logo ******************************************************************/

	.head .logo {
		float: right;
		margin: 0.4rem 0 0.2rem .4rem;
	}

	.head img[src*="logos/W3C"] {
		display: block;
		border: solid #1a5e9a;
		border-width: .65rem .7rem .6rem;
		border-radius: .4rem;
		background: #1a5e9a;
		color: white;
		font-weight: bold;
	}

	.head a:hover > img[src*="logos/W3C"],
	.head a:focus > img[src*="logos/W3C"] {
		opacity: .8;
	}

	.head a:active > img[src*="logos/W3C"] {
		background: #c00;
		border-color: #c00;
	}

	/* see also additional rules in Link Styling section */

/** Copyright *****************************************************************/

	p.copyright,
	p.copyright small { font-size: small }

/** Back to Top / ToC Toggle **************************************************/

	@media print {
		#toc-nav {
			display: none;
		}
	}
	@media not print {
		#toc-nav {
			position: fixed;
			z-index: 2;
			bottom: 0; left: 0;
			margin: 0;
			min-width: 1.33em;
			border-top-right-radius: 2rem;
			box-shadow: 0 0 2px;
			font-size: 1.5em;
			color: black;
		}
		#toc-nav > a {
			display: block;
			white-space: nowrap;

			height: 1.33em;
			padding: .1em 0.3em;
			margin: 0;

			background: white;
			box-shadow: 0 0 2px;
			border: none;
			border-top-right-radius: 1.33em;
			background: white;
		}
		#toc-nav > #toc-jump {
			padding-bottom: 2em;
			margin-bottom: -1.9em;
		}

		#toc-nav > a:hover,
		#toc-nav > a:focus {
			background: #f8f8f8;
		}
		#toc-nav > a:not(:hover):not(:focus) {
			color: #707070;
		}

		/* statusbar gets in the way on keyboard focus; remove once browsers fix */
		#toc-nav > a[href="#toc"]:not(:hover):focus:last-child {
			padding-bottom: 1.5rem;
		}

		#toc-nav:not(:hover) > a:not(:focus) > span + span {
			/* Ideally this uses :focus-within on #toc-nav */
			display: none;
		}
		#toc-nav > a > span + span {
			padding-right: 0.2em;
		}

		#toc-toggle-inline {
			vertical-align: 0.05em;
			font-size: 80%;
			color: gray;
			color: hsla(203,20%,40%,.7);
			border-style: none;
			background: transparent;
			position: relative;
		}
		#toc-toggle-inline:hover:not(:active),
		#toc-toggle-inline:focus:not(:active) {
			text-shadow: 1px 1px silver;
			top: -1px;
			left: -1px;
		}

		#toc-nav :active {
			color: #C00;
		}
	}

/** ToC Sidebar ***************************************************************/

	/* Floating sidebar */
	@media screen {
		body.toc-sidebar #toc {
			position: fixed;
			top: 0; bottom: 0;
			left: 0;
			width: 23.5em;
			max-width: 80%;
			max-width: calc(100% - 2em - 26px);
			overflow: auto;
			padding: 0 1em;
			padding-left: 42px;
			padding-left: calc(1em + 26px);
			background: inherit;
			background-color: #f7f8f9;
			z-index: 1;
			box-shadow: -.1em 0 .25em rgba(0,0,0,.1) inset;
		}
		body.toc-sidebar #toc h2 {
			margin-top: .8rem;
			font-variant: small-caps;
			font-variant: all-small-caps;
			text-transform: lowercase;
			font-weight: bold;
			color: gray;
			color: hsla(203,20%,40%,.7);
		}
		body.toc-sidebar #toc-jump:not(:focus) {
			width: 0;
			height: 0;
			padding: 0;
			position: absolute;
			overflow: hidden;
		}
	}
	/* Hide main scroller when only the ToC is visible anyway */
	@media screen and (max-width: 28em) {
		body.toc-sidebar {
			overflow: hidden;
		}
	}

	/* Sidebar with its own space */
	@media screen and (min-width: 78em) {
		body:not(.toc-inline) #toc {
			position: fixed;
			top: 0; bottom: 0;
			left: 0;
			width: 23.5em;
			overflow: auto;
			padding: 0 1em;
			padding-left: 42px;
			padding-left: calc(1em + 26px);
			background: inherit;
			background-color: #f7f8f9;
			z-index: 1;
			box-shadow: -.1em 0 .25em rgba(0,0,0,.1) inset;
		}
		body:not(.toc-inline) #toc h2 {
			margin-top: .8rem;
			font-variant: small-caps;
			font-variant: all-small-caps;
			text-transform: lowercase;
			font-weight: bold;
			color: gray;
			color: hsla(203,20%,40%,.7);
		}

		body:not(.toc-inline) {
			padding-left: 29em;
		}
		/* See also Overflow section at the bottom */

		body:not(.toc-inline) #toc-jump:not(:focus) {
			width: 0;
			height: 0;
			padding: 0;
			position: absolute;
			overflow: hidden;
		}
	}
	@media screen and (min-width: 90em) {
		body:not(.toc-inline) {
			margin: 0 4em;
		}
	}

/******************************************************************************/
/*                                Sectioning                                  */
/******************************************************************************/

/** Headings ******************************************************************/

	h1, h2, h3, h4, h5, h6, dt {
		page-break-after: avoid;
		page-break-inside: avoid;
		font: 100% sans-serif;   /* Reset all font styling to clear out UA styles */
		font-family: inherit;    /* Inherit the font family. */
		line-height: 1.2;        /* Keep wrapped headings compact */
		hyphens: manual;         /* Hyphenated headings look weird */
	}

	h2, h3, h4, h5, h6 {
		margin-top: 3rem;
	}

	h1, h2, h3 {
		color: #005A9C;
		background: transparent;
	}

	h1 { font-size: 170%; }
	h2 { font-size: 140%; }
	h3 { font-size: 120%; }
	h4 { font-weight: bold; }
	h5 { font-style: italic; }
	h6 { font-variant: small-caps; }
	dt { font-weight: bold; }

/** Subheadings ***************************************************************/

	h1 + h2,
	#subtitle {
		/* #subtitle is a subtitle in an H2 under the H1 */
		margin-top: 0;
	}
	h2 + h3,
	h3 + h4,
	h4 + h5,
	h5 + h6 {
		margin-top: 1.2em; /* = 1 x line-height */
	}

/** Section divider ***********************************************************/

	:not(.head) > hr {
		font-size: 1.5em;
		text-align: center;
		margin: 1em auto;
		height: auto;
		border: transparent solid 0;
		background: transparent;
	}
	:not(.head) > hr::before {
		content: "\2727\2003\2003\2727\2003\2003\2727";
	}

/******************************************************************************/
/*                            Paragraphs and Lists                            */
/******************************************************************************/

	p {
		margin: 1em 0;
	}

	dd > p:first-child,
	li > p:first-child {
		margin-top: 0;
	}

	ul, ol {
		margin-left: 0;
		padding-left: 2em;
	}

	li {
		margin: 0.25em 0 0.5em;
		padding: 0;
	}

	dl dd {
		margin: 0 0 .5em 2em;
	}

	.head dd + dd { /* compact for header */
		margin-top: -.5em;
	}

	/* Style for algorithms */
	ol.algorithm ol:not(.algorithm),
	.algorithm > ol ol:not(.algorithm) {
	 border-left: 0.5em solid #DEF;
	}
	/* removed for section as it cut through the underline of the anchor */
	section.algorithm[data-algorithm] {
	  border-style: hidden;
	}
	/* Put nice boxes around each algorithm. */
	[data-algorithm]:not(.heading) {
	  padding: .5em;
	  border: thin solid #ddd; border-radius: .5em;
	  margin: .5em 0;
	}
	[data-algorithm]:not(.heading) > :first-child {
	  margin-top: 0;
	}
	[data-algorithm]:not(.heading) > :last-child {
	  margin-bottom: 0;
	}

	/* Style for switch/case <dl>s */
	dl.switch > dd > ol.only,
	dl.switch > dd > .only > ol {
	 margin-left: 0;
	}
	dl.switch > dd > ol.algorithm,
	dl.switch > dd > .algorithm > ol {
	 margin-left: -2em;
	}
	dl.switch {
	 padding-left: 2em;
	}
	dl.switch > dt {
	 text-indent: -1.5em;
	 margin-top: 1em;
	}
	dl.switch > dt + dt {
	 margin-top: 0;
	}
	dl.switch > dt::before {
	 content: '\21AA';
	 padding: 0 0.5em 0 0;
	 display: inline-block;
	 width: 1em;
	 text-align: right;
	 line-height: 0.5em;
	}

/** Terminology Markup ********************************************************/


/******************************************************************************/
/*                                 Inline Markup                              */
/******************************************************************************/

/** Terminology Markup ********************************************************/
	dfn   { /* Defining instance */
		font-weight: bolder;
	}
	a > i { /* Instance of term */
		font-style: normal;
	}
	dt dfn code, code.idl {
		font-size: medium;
	}
	dfn var {
		font-style: normal;
	}

/** Change Marking ************************************************************/

	del { color: red;  text-decoration: line-through; }
	ins { color: #080; text-decoration: underline;    }

/** Miscellaneous improvements to inline formatting ***************************/

	sup {
		vertical-align: super;
		font-size: 80%
	}

/******************************************************************************/
/*                                    Code                                    */
/******************************************************************************/

/** General monospace/pre rules ***********************************************/

	pre, code, samp {
		font-family: Menlo, Consolas, "DejaVu Sans Mono", Monaco, monospace;
		font-size: .9em;
		page-break-inside: avoid;
		hyphens: none;
		text-transform: none;
	}
	pre code,
	code code {
		font-size: 100%;
	}

	pre {
		margin-top: 1em;
		margin-bottom: 1em;
		overflow: auto;
	}

/** Inline Code fragments *****************************************************/

  /* Do something nice. */

/******************************************************************************/
/*                                    Links                                   */
/******************************************************************************/

/** General Hyperlinks ********************************************************/

	/* We hyperlink a lot, so make it less intrusive */
	a[href] {
		color: #034575;
		text-decoration: none;
		border-bottom: 1px solid #707070;
		/* Need a bit of extending for it to look okay */
		padding: 0 1px 0;
		margin: 0 -1px 0;
	}
	a:visited {
		border-bottom-color: #BBB;
	}

	/* Use distinguishing colors when user is interacting with the link */
	a[href]:focus,
	a[href]:hover {
		background: #f8f8f8;
		background: rgba(75%, 75%, 75%, .25);
		border-bottom-width: 3px;
		margin-bottom: -2px;
	}
	a[href]:active {
		color: #C00;
		border-color: #C00;
	}

	/* Backout above styling for W3C logo */
	.head .logo,
	.head .logo a {
		border: none;
		text-decoration: none;
		background: transparent;
	}

/******************************************************************************/
/*                                    Images                                  */
/******************************************************************************/

	img {
		border-style: none;
	}

	/* For autogen numbers, add
	   .caption::before, figcaption::before { content: "Figure " counter(figure) ". "; }
	*/

	figure, .figure, .sidefigure {
		page-break-inside: avoid;
		text-align: center;
		margin: 2.5em 0;
	}
	.figure img,    .sidefigure img,    figure img,
	.figure object, .sidefigure object, figure object {
		max-width: 100%;
		margin: auto;
	}
	.figure pre, .sidefigure pre, figure pre {
		text-align: left;
		display: table;
		margin: 1em auto;
	}
	.figure table, figure table {
		margin: auto;
	}
	@media screen and (min-width: 20em) {
		.sidefigure {
			float: right;
			width: 50%;
			margin: 0 0 0.5em 0.5em
		}
	}
	.caption, figcaption, caption {
		font-style: italic;
		font-size: 90%;
	}
	.caption::before, figcaption::before, figcaption > .marker {
		font-weight: bold;
	}
	.caption, figcaption {
		counter-increment: figure;
	}

	/* DL list is indented 2em, but figure inside it is not */
	dd > .figure, dd > figure { margin-left: -2em }

/******************************************************************************/
/*                             Colored Boxes                                  */
/******************************************************************************/

	.issue, .note, .example, .assertion, .advisement, blockquote {
		padding: .5em;
		border: .5em;
		border-left-style: solid;
		page-break-inside: avoid;
	}
	span.issue, span.note {
		padding: .1em .5em .15em;
		border-right-style: solid;
	}

	.issue,
	.note,
	.example,
	.advisement,
	.assertion,
	blockquote {
		margin: 1em auto;
	}
	.note  > p:first-child,
	.issue > p:first-child,
	blockquote > :first-child {
		margin-top: 0;
	}
	blockquote > :last-child {
		margin-bottom: 0;
	}

/** Blockquotes ***************************************************************/

	blockquote {
		border-color: silver;
	}

/** Open issue ****************************************************************/

	.issue {
		border-color: #E05252;
		background: #FBE9E9;
		counter-increment: issue;
		overflow: auto;
	}
	.issue::before, .issue > .marker {
		text-transform: uppercase;
		color: #AE1E1E;
		padding-right: 1em;
		text-transform: uppercase;
	}
	/* Add .issue::before { content: "Issue " counter(issue) " "; } for autogen numbers,
	   or use class="marker" to mark up the issue number in source. */

/** Example *******************************************************************/

	.example {
		border-color: #E0CB52;
		background: #FCFAEE;
		counter-increment: example;
		overflow: auto;
		clear: both;
	}
	.example::before, .example > .marker {
		text-transform: uppercase;
		color: #827017;
		min-width: 7.5em;
		display: block;
	}
	/* Add .example::before { content: "Example " counter(example) " "; } for autogen numbers,
	   or use class="marker" to mark up the example number in source. */

/** Non-normative Note ********************************************************/

	.note {
		border-color: #52E052;
		background: #E9FBE9;
		overflow: auto;
	}

	.note::before, .note > .marker,
	details.note > summary::before,
	details.note > summary > .marker {
		text-transform: uppercase;
		display: block;
		color: hsl(120, 70%, 30%);
	}
	/* Add .note::before { content: "Note"; } for autogen label,
	   or use class="marker" to mark up the label in source. */

	details.note > summary {
		display: block;
		color: hsl(120, 70%, 30%);
	}
	details.note[open] > summary {
		border-bottom: 1px silver solid;
	}

/** Assertion Box *************************************************************/
	/*  for assertions in algorithms */

	.assertion {
		border-color: #AAA;
		background: #EEE;
	}

/** Advisement Box ************************************************************/
	/*  for attention-grabbing normative statements */

	.advisement {
		border-color: orange;
		border-style: none solid;
		background: #FFEECC;
	}
	strong.advisement {
		display: block;
		text-align: center;
	}
	.advisement > .marker {
		color: #B35F00;
	}

/** Spec Obsoletion Notice ****************************************************/
	/* obnoxious obsoletion notice for older/abandoned specs. */

	details {
		display: block;
	}
	summary {
		font-weight: bolder;
	}

	.annoying-warning:not(details),
	details.annoying-warning:not([open]) > summary,
	details.annoying-warning[open] {
		background: #fdd;
		color: red;
		font-weight: bold;
		padding: .75em 1em;
		border: thick red;
		border-style: solid;
		border-radius: 1em;
	}
	.annoying-warning :last-child {
		margin-bottom: 0;
	}

@media not print {
	details.annoying-warning[open] {
		position: fixed;
		left: 1em;
		right: 1em;
		bottom: 1em;
		z-index: 1000;
	}
}

	details.annoying-warning:not([open]) > summary {
		text-align: center;
	}

/** Entity Definition Boxes ***************************************************/

	.def {
		padding: .5em 1em;
		background: #DEF;
		margin: 1.2em 0;
		border-left: 0.5em solid #8CCBF2;
	}

/******************************************************************************/
/*                                    Tables                                  */
/******************************************************************************/

	th, td {
		text-align: left;
		text-align: start;
	}

/** Property/Descriptor Definition Tables *************************************/

	table.def {
		/* inherits .def box styling, see above */
		width: 100%;
		border-spacing: 0;
	}

	table.def td,
	table.def th {
		padding: 0.5em;
		vertical-align: baseline;
		border-bottom: 1px solid #bbd7e9;
	}

	table.def > tbody > tr:last-child th,
	table.def > tbody > tr:last-child td {
		border-bottom: 0;
	}

	table.def th {
		font-style: italic;
		font-weight: normal;
		padding-left: 1em;
		width: 3em;
	}

	/* For when values are extra-complex and need formatting for readability */
	table td.pre {
		white-space: pre-wrap;
	}

	/* A footnote at the bottom of a def table */
	table.def           td.footnote {
		padding-top: 0.6em;
	}
	table.def           td.footnote::before {
		content: " ";
		display: block;
		height: 0.6em;
		width: 4em;
		border-top: thin solid;
	}

/** Data tables (and properly marked-up index tables) *************************/
	/*
		 <table class="data"> highlights structural relationships in a table
		 when correct markup is used (e.g. thead/tbody, th vs. td, scope attribute)

		 Use class="complex data" for particularly complicated tables --
		 (This will draw more lines: busier, but clearer.)

		 Use class="long" on table cells with paragraph-like contents
		 (This will adjust text alignment accordingly.)
		 Alternately use class="longlastcol" on tables, to have the last column assume "long".
	*/

	table {
		word-wrap: normal;
		overflow-wrap: normal;
		hyphens: manual;
	}

	table.data,
	table.index {
		margin: 1em auto;
		border-collapse: collapse;
		border: hidden;
		width: 100%;
	}
	table.data caption,
	table.index caption {
		max-width: 50em;
		margin: 0 auto 1em;
	}

	table.data td,  table.data th,
	table.index td, table.index th {
		padding: 0.5em 1em;
		border-width: 1px;
		border-color: silver;
		border-top-style: solid;
	}

	table.data thead td:empty {
		padding: 0;
		border: 0;
	}

	table.data  thead,
	table.index thead,
	table.data  tbody,
	table.index tbody {
		border-bottom: 2px solid;
	}

	table.data colgroup,
	table.index colgroup {
		border-left: 2px solid;
	}

	table.data  tbody th:first-child,
	table.index tbody th:first-child  {
		border-right: 2px solid;
		border-top: 1px solid silver;
		padding-right: 1em;
	}

	table.data th[colspan],
	table.data td[colspan] {
		text-align: center;
	}

	table.complex.data th,
	table.complex.data td {
		border: 1px solid silver;
		text-align: center;
	}

	table.data.longlastcol td:last-child,
	table.data td.long {
	 vertical-align: baseline;
	 text-align: left;
	}

	table.data img {
		vertical-align: middle;
	}


/*
Alternate table alignment rules

	table.data,
	table.index {
		text-align: center;
	}

	table.data  thead th[scope="row"],
	table.index thead th[scope="row"] {
		text-align: right;
	}

	table.data  tbody th:first-child,
	table.index tbody th:first-child  {
		text-align: right;
	}

Possible extra rowspan handling

	table.data  tbody th[rowspan]:not([rowspan='1']),
	table.index tbody th[rowspan]:not([rowspan='1']),
	table.data  tbody td[rowspan]:not([rowspan='1']),
	table.index tbody td[rowspan]:not([rowspan='1']) {
		border-left: 1px solid silver;
	}

	table.data  tbody th[rowspan]:first-child,
	table.index tbody th[rowspan]:first-child,
	table.data  tbody td[rowspan]:first-child,
	table.index tbody td[rowspan]:first-child{
		border-left: 0;
		border-right: 1px solid silver;
	}
*/

/******************************************************************************/
/*                                  Indices                                   */
/******************************************************************************/


/** Table of Contents *********************************************************/

	.toc a {
		/* More spacing; use padding to make it part of the click target. */
		padding-top: 0.1rem;
		/* Larger, more consistently-sized click target */
		display: block;
		/* Reverse color scheme */
		color: black;
		border-color: #3980B5;
	}
	.toc a:visited {
		border-color: #054572;
	}
	.toc a:not(:focus):not(:hover) {
		/* Allow colors to cascade through from link styling */
		border-bottom-color: transparent;
	}

	.toc, .toc ol, .toc ul, .toc li {
		list-style: none; /* Numbers must be inlined into source */
		/* because generated content isn't search/selectable and markers can't do multilevel yet */
		margin:  0;
		padding: 0;
		line-height: 1.1rem; /* consistent spacing */
	}

	/* ToC not indented until third level, but font style & margins show hierarchy */
	.toc > li             { font-weight: bold;   }
	.toc > li li          { font-weight: normal; }
	.toc > li li li       { font-size:   95%;    }
	.toc > li li li li    { font-size:   90%;    }
	.toc > li li li li li { font-size:   85%;    }

	.toc > li             { margin: 1.5rem 0;    }
	.toc > li li          { margin: 0.3rem 0;    }
	.toc > li li li       { margin-left: 2rem;   }

	/* Section numbers in a column of their own */
	.toc .secno {
		float: left;
		width: 4rem;
		white-space: nowrap;
	}
	.toc > li li li li .secno {
		font-size: 85%;
	}
	.toc > li li li li li .secno {
		font-size: 100%;
	}

	:not(li) > .toc              { margin-left:  5rem; }
	.toc .secno                  { margin-left: -5rem; }
	.toc > li li li .secno       { margin-left: -7rem; }
	.toc > li li li li .secno    { margin-left: -9rem; }
	.toc > li li li li li .secno { margin-left: -11rem; }

	/* Tighten up indentation in narrow ToCs */
	@media (max-width: 30em) {
		:not(li) > .toc              { margin-left:  4rem; }
		.toc .secno                  { margin-left: -4rem; }
		.toc > li li li              { margin-left:  1rem; }
		.toc > li li li .secno       { margin-left: -5rem; }
		.toc > li li li li .secno    { margin-left: -6rem; }
		.toc > li li li li li .secno { margin-left: -7rem; }
	}
	@media screen and (min-width: 78em) {
		body:not(.toc-inline) :not(li) > .toc              { margin-left:  4rem; }
		body:not(.toc-inline) .toc .secno                  { margin-left: -4rem; }
		body:not(.toc-inline) .toc > li li li              { margin-left:  1rem; }
		body:not(.toc-inline) .toc > li li li .secno       { margin-left: -5rem; }
		body:not(.toc-inline) .toc > li li li li .secno    { margin-left: -6rem; }
		body:not(.toc-inline) .toc > li li li li li .secno { margin-left: -7rem; }
	}
	body.toc-sidebar #toc :not(li) > .toc              { margin-left:  4rem; }
	body.toc-sidebar #toc .toc .secno                  { margin-left: -4rem; }
	body.toc-sidebar #toc .toc > li li li              { margin-left:  1rem; }
	body.toc-sidebar #toc .toc > li li li .secno       { margin-left: -5rem; }
	body.toc-sidebar #toc .toc > li li li li .secno    { margin-left: -6rem; }
	body.toc-sidebar #toc .toc > li li li li li .secno { margin-left: -7rem; }

	.toc li {
		clear: both;
	}


/** Index *********************************************************************/

	/* Index Lists: Layout */
	ul.index       { margin-left: 0; columns: 15em; text-indent: 1em hanging; }
	ul.index li    { margin-left: 0; list-style: none; break-inside: avoid; }
	ul.index li li { margin-left: 1em }
	ul.index dl    { margin-top: 0; }
	ul.index dt    { margin: .2em 0 .2em 20px;}
	ul.index dd    { margin: .2em 0 .2em 40px;}
	/* Index Lists: Typography */
	ul.index ul,
	ul.index dl { font-size: smaller; }
	@media not print {
		ul.index li span {
			white-space: nowrap;
			color: transparent; }
		ul.index li a:hover + span,
		ul.index li a:focus + span {
			color: #707070;
		}
	}

/** Index Tables *****************************************************/
	/* See also the data table styling section, which this effectively subclasses */

	table.index {
		font-size: small;
		border-collapse: collapse;
		border-spacing: 0;
		text-align: left;
		margin: 1em 0;
	}

	table.index td,
	table.index th {
		padding: 0.4em;
	}

	table.index tr:hover td:not([rowspan]),
	table.index tr:hover th:not([rowspan]) {
		background: #f7f8f9;
	}

	/* The link in the first column in the property table (formerly a TD) */
	table.index th:first-child a {
		font-weight: bold;
	}

/******************************************************************************/
/*                                    Print                                   */
/******************************************************************************/

	@media print {
		/* Pages have their own margins. */
		html {
			margin: 0;
		}
		/* Serif for print. */
		body {
			font-family: serif;
		}
	}
	@page {
		margin: 1.5cm 1.1cm;
	}

/******************************************************************************/
/*                                    Legacy                                  */
/******************************************************************************/

	/* This rule is inherited from past style sheets. No idea what it's for. */
	.hide { display: none }



/******************************************************************************/
/*                             Overflow Control                               */
/******************************************************************************/

	.figure .caption, .sidefigure .caption, figcaption {
		/* in case figure is overlarge, limit caption to 50em */
		max-width: 50rem;
		margin-left: auto;
		margin-right: auto;
	}
	.overlarge > table {
		/* limit preferred width of table */
		max-width: 50em;
		margin-left: auto;
		margin-right: auto;
	}

	@media (min-width: 55em) {
		.overlarge {
			margin-left: calc(13px + 26.5rem - 50vw);
			margin-right: calc(13px + 26.5rem - 50vw);
			max-width: none;
		}
	}
	@media screen and (min-width: 78em) {
		body:not(.toc-inline) .overlarge {
			/* 30.5em body padding 50em content area */
			margin-left: calc(40em - 50vw) !important;
			margin-right: calc(40em - 50vw) !important;
		}
	}
	@media screen and (min-width: 90em) {
		body:not(.toc-inline) .overlarge {
			/* 4em html margin 30.5em body padding 50em content area */
			margin-left: 0 !important;
			margin-right: calc(84.5em - 100vw) !important;
		}
	}

	@media not print {
		.overlarge {
			overflow-x: auto;
			/* See Lea Verou's explanation background-attachment:
			 * http://lea.verou.me/2012/04/background-attachment-local/
			 *
			background: top left  / 4em 100% linear-gradient(to right,  #ffffff, rgba(255, 255, 255, 0)) local,
			            top right / 4em 100% linear-gradient(to left, #ffffff, rgba(255, 255, 255, 0)) local,
			            top left  / 1em 100% linear-gradient(to right,  #c3c3c5, rgba(195, 195, 197, 0)) scroll,
			            top right / 1em 100% linear-gradient(to left, #c3c3c5, rgba(195, 195, 197, 0)) scroll,
			            white;
			background-repeat: no-repeat;
			*/
		}
	}
</style>
  <meta content="Bikeshed 1.0.0" name="generator">
<style>/* style-md-lists */

            /* This is a weird hack for me not yet following the commonmark spec
               regarding paragraph and lists. */
            [data-md] > :first-child {
                margin-top: 0;
            }
            [data-md] > :last-child {
                margin-bottom: 0;
            }</style>
<style>/* style-selflinks */

            .heading, .issue, .note, .example, li, dt {
                position: relative;
            }
            a.self-link {
                position: absolute;
                top: 0;
                left: calc(-1 * (3.5rem - 26px));
                width: calc(3.5rem - 26px);
                height: 2em;
                text-align: center;
                border: none;
                transition: opacity .2s;
                opacity: .5;
            }
            a.self-link:hover {
                opacity: 1;
            }
            .heading > a.self-link {
                font-size: 83%;
            }
            li > a.self-link {
                left: calc(-1 * (3.5rem - 26px) - 2em);
            }
            dfn > a.self-link {
                top: auto;
                left: auto;
                opacity: 0;
                width: 1.5em;
                height: 1.5em;
                background: gray;
                color: white;
                font-style: normal;
                transition: opacity .2s, background-color .2s, color .2s;
            }
            dfn:hover > a.self-link {
                opacity: 1;
            }
            dfn > a.self-link:hover {
                color: black;
            }

            a.self-link::before            { content: "¶"; }
            .heading > a.self-link::before { content: "§"; }
            dfn > a.self-link::before      { content: "#"; }</style>
<style>/* style-counters */

            body {
                counter-reset: example figure issue;
            }
            .issue {
                counter-increment: issue;
            }
            .issue:not(.no-marker)::before {
                content: "Issue " counter(issue);
            }

            .example {
                counter-increment: example;
            }
            .example:not(.no-marker)::before {
                content: "Example " counter(example);
            }
            .invalid.example:not(.no-marker)::before,
            .illegal.example:not(.no-marker)::before {
                content: "Invalid Example" counter(example);
            }

            figcaption {
                counter-increment: figure;
            }
            figcaption:not(.no-marker)::before {
                content: "Figure " counter(figure) " ";
            }</style>
<style>/* style-autolinks */

            .css.css, .property.property, .descriptor.descriptor {
                color: #005a9c;
                font-size: inherit;
                font-family: inherit;
            }
            .css::before, .property::before, .descriptor::before {
                content: "‘";
            }
            .css::after, .property::after, .descriptor::after {
                content: "’";
            }
            .property, .descriptor {
                /* Don't wrap property and descriptor names */
                white-space: nowrap;
            }
            .type { /* CSS value <type> */
                font-style: italic;
            }
            pre .property::before, pre .property::after {
                content: "";
            }
            [data-link-type="property"]::before,
            [data-link-type="propdesc"]::before,
            [data-link-type="descriptor"]::before,
            [data-link-type="value"]::before,
            [data-link-type="function"]::before,
            [data-link-type="at-rule"]::before,
            [data-link-type="selector"]::before,
            [data-link-type="maybe"]::before {
                content: "‘";
            }
            [data-link-type="property"]::after,
            [data-link-type="propdesc"]::after,
            [data-link-type="descriptor"]::after,
            [data-link-type="value"]::after,
            [data-link-type="function"]::after,
            [data-link-type="at-rule"]::after,
            [data-link-type="selector"]::after,
            [data-link-type="maybe"]::after {
                content: "’";
            }

            [data-link-type].production::before,
            [data-link-type].production::after,
            .prod [data-link-type]::before,
            .prod [data-link-type]::after {
                content: "";
            }

            [data-link-type=element],
            [data-link-type=element-attr] {
                font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
                font-size: .9em;
            }
            [data-link-type=element]::before { content: "<" }
            [data-link-type=element]::after  { content: ">" }

            [data-link-type=biblio] {
                white-space: pre;
            }</style>
<style>/* style-dfn-panel */

        .dfn-panel {
            position: absolute;
            z-index: 35;
            height: auto;
            width: -webkit-fit-content;
            width: fit-content;
            max-width: 300px;
            max-height: 500px;
            overflow: auto;
            padding: 0.5em 0.75em;
            font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
            background: #DDDDDD;
            color: black;
            border: outset 0.2em;
        }
        .dfn-panel:not(.on) { display: none; }
        .dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
        .dfn-panel > b { display: block; }
        .dfn-panel a { color: black; }
        .dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
        .dfn-panel > b + b { margin-top: 0.25em; }
        .dfn-panel ul { padding: 0; }
        .dfn-panel li { list-style: inside; }
        .dfn-panel.activated {
            display: inline-block;
            position: fixed;
            left: .5em;
            bottom: 2em;
            margin: 0 auto;
            max-width: calc(100vw - 1.5em - .4em - .5em);
            max-height: 30vh;
        }

        .dfn-paneled { cursor: pointer; }
        </style>
<style>/* style-syntax-highlighting */
pre.idl.highlight { color: #708090; }
        .highlight:not(.idl) { background: hsl(24, 20%, 95%); }
        code.highlight { padding: .1em; border-radius: .3em; }
        pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; }
        .highlight .c { color: #708090 } /* Comment */
        .highlight .k { color: #990055 } /* Keyword */
        .highlight .l { color: #000000 } /* Literal */
        .highlight .n { color: #0077aa } /* Name */
        .highlight .o { color: #999999 } /* Operator */
        .highlight .p { color: #999999 } /* Punctuation */
        .highlight .cm { color: #708090 } /* Comment.Multiline */
        .highlight .cp { color: #708090 } /* Comment.Preproc */
        .highlight .c1 { color: #708090 } /* Comment.Single */
        .highlight .cs { color: #708090 } /* Comment.Special */
        .highlight .kc { color: #990055 } /* Keyword.Constant */
        .highlight .kd { color: #990055 } /* Keyword.Declaration */
        .highlight .kn { color: #990055 } /* Keyword.Namespace */
        .highlight .kp { color: #990055 } /* Keyword.Pseudo */
        .highlight .kr { color: #990055 } /* Keyword.Reserved */
        .highlight .kt { color: #990055 } /* Keyword.Type */
        .highlight .ld { color: #000000 } /* Literal.Date */
        .highlight .m { color: #000000 } /* Literal.Number */
        .highlight .s { color: #a67f59 } /* Literal.String */
        .highlight .na { color: #0077aa } /* Name.Attribute */
        .highlight .nc { color: #0077aa } /* Name.Class */
        .highlight .no { color: #0077aa } /* Name.Constant */
        .highlight .nd { color: #0077aa } /* Name.Decorator */
        .highlight .ni { color: #0077aa } /* Name.Entity */
        .highlight .ne { color: #0077aa } /* Name.Exception */
        .highlight .nf { color: #0077aa } /* Name.Function */
        .highlight .nl { color: #0077aa } /* Name.Label */
        .highlight .nn { color: #0077aa } /* Name.Namespace */
        .highlight .py { color: #0077aa } /* Name.Property */
        .highlight .nt { color: #669900 } /* Name.Tag */
        .highlight .nv { color: #222222 } /* Name.Variable */
        .highlight .ow { color: #999999 } /* Operator.Word */
        .highlight .mb { color: #000000 } /* Literal.Number.Bin */
        .highlight .mf { color: #000000 } /* Literal.Number.Float */
        .highlight .mh { color: #000000 } /* Literal.Number.Hex */
        .highlight .mi { color: #000000 } /* Literal.Number.Integer */
        .highlight .mo { color: #000000 } /* Literal.Number.Oct */
        .highlight .sb { color: #a67f59 } /* Literal.String.Backtick */
        .highlight .sc { color: #a67f59 } /* Literal.String.Char */
        .highlight .sd { color: #a67f59 } /* Literal.String.Doc */
        .highlight .s2 { color: #a67f59 } /* Literal.String.Double */
        .highlight .se { color: #a67f59 } /* Literal.String.Escape */
        .highlight .sh { color: #a67f59 } /* Literal.String.Heredoc */
        .highlight .si { color: #a67f59 } /* Literal.String.Interpol */
        .highlight .sx { color: #a67f59 } /* Literal.String.Other */
        .highlight .sr { color: #a67f59 } /* Literal.String.Regex */
        .highlight .s1 { color: #a67f59 } /* Literal.String.Single */
        .highlight .ss { color: #a67f59 } /* Literal.String.Symbol */
        .highlight .vc { color: #0077aa } /* Name.Variable.Class */
        .highlight .vg { color: #0077aa } /* Name.Variable.Global */
        .highlight .vi { color: #0077aa } /* Name.Variable.Instance */
        .highlight .il { color: #000000 } /* Literal.Number.Integer.Long */
        </style>
  <link rel="stylesheet" type="text/css" href="https://www.w3.org/StyleSheets/TR/2016/W3C-WD"/>
 <body class="h-entry">
  <div class="head">
   <p data-fill-with="logo"><a href="https://www.w3.org/"><img height="48" width="72" alt="W3C" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C"/></a> </p>
   <h1 class="p-name no-ref" id="title">Service Workers 1</h1>
   <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">W3C Working Draft, <time class="dt-updated" datetime="2016-10-11">11 October 2016</time></span></h2>
   <div data-fill-with="spec-metadata">
    <dl>
     <dt>This version:
     <dd><a class="u-url" href="https://www.w3.org/TR/2016/WD-service-workers-1-20161011/">https://www.w3.org/TR/2016/WD-service-workers-1-20161011/</a>
     <dt>Latest published version:
     <dd><a href="https://www.w3.org/TR/service-workers-1/">https://www.w3.org/TR/service-workers-1/</a>
     <dt>Editor's Draft:
     <dd><a href="https://w3c.github.io/ServiceWorker/v1/">https://w3c.github.io/ServiceWorker/v1/</a>
     <dt>Previous Versions:
     <dd><a href="https://www.w3.org/TR/2015/WD-service-workers-20150625/" rel="previous">https://www.w3.org/TR/2015/WD-service-workers-20150625/</a>
     <dt>Feedback:
     <dd><span><a href="mailto:public-webapps@w3.org?subject=%5Bservice-workers%5D%20YOUR%20TOPIC%20HERE">public-webapps@w3.org</a> with subject line “<kbd>[service-workers] <i data-lt="">… message topic …</i></kbd>” (<a href="http://lists.w3.org/Archives/Public/public-webapps/" rel="discussion">archives</a>)</span>
     <dt>Issue Tracking:
     <dd><a href="https://github.com/w3c/ServiceWorker/issues/">GitHub</a>
     <dd><a href="#issues-index">Inline In Spec</a>
     <dt class="editor">Editors:
     <dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:slightlyoff@chromium.org">Alex Russell</a> (<span class="p-org org">Google</span>)
     <dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:jungkee.song@samsung.com">Jungkee Song</a> (<span class="p-org org">Samsung Electronics</span>)
     <dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:jakearchibald@chromium.org">Jake Archibald</a> (<span class="p-org org">Google</span>)
     <dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:mek@chromium.org">Marijn Kruisselbrink</a> (<span class="p-org org">Google</span>)
    </dl>
   </div>
   <div data-fill-with="warning"></div>
   <p class="copyright"><a href="https://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2016 <a href="https://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="https://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="https://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="https://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>). W3C <a href="https://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="https://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>
   <hr title="Separator for header">
  </div>
  <h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
  <div class="p-summary" data-fill-with="abstract">
   <p>This specification describes a method that enables applications to take advantage of persistent background processing, including hooks to enable bootstrapping of web applications while offline.</p>
   <p>The core of this system is an event-driven <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#workers">Web Worker</a>, which responds to events dispatched from documents and other sources. A system for managing installation, versions, and upgrades is provided.</p>
   <p>The service worker is a generic entry point for event-driven background processing in the Web Platform that is <a href="#extensibility">extensible by other specifications</a>.</p>
  </div>
  <h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
  <div data-fill-with="status">
   <p> <em>This section describes the status of this document at the time of
  its publication. Other documents may supersede this document. A list of
  current W3C publications and the latest revision of this technical report
  can be found in the <a href="https://www.w3.org/TR/">W3C technical reports
  index at https://www.w3.org/TR/.</a></em> </p>
   <p> This document was published by the <a href="https://www.w3.org/WebPlatform/WG/">Web Platform Working Group</a> as a Working Draft. This document is intended to become a W3C Recommendation. </p>
   <p> If you wish to make comments regarding this document, please send them to this specification’s <a href="https://github.com/w3c/ServiceWorker">GitHub repository</a> or (<a href="http://lists.w3.org/Archives/Public/public-webapps/">archived</a>) public mailing list <a href="mailto:public-webapps@w3.org?Subject=%5Bservice-workers%5D%20PUT%20SUBJECT%20HERE">public-webapps@w3.org</a> (see <a href="http://www.w3.org/Mail/Request">instructions</a>). When sending e-mail, please put the text “service-workers” in the subject, preferably like this: “[service-workers] <em>…summary of comment…</em>. All comments are welcome. </p>
   <p> Publication as a Working Draft does not imply endorsement by the W3C
  Membership. This is a draft document and may be updated, replaced or
  obsoleted by other documents at any time. It is inappropriate to cite this
  document as other than work in progress. </p>
   <p> This document was produced by a group operating under the <a class="css" data-link-type="property" href="https://www.w3.org/Consortium/Patent-Policy-20040205/" id="sotd_patent">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="https://www.w3.org/2004/01/pp-impl/83482/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="https://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="https://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. </p>
   <p> This document is governed by the <a href="https://www.w3.org/2015/Process-20150901/" id="w3c_process_revision">1 September 2015 W3C Process Document</a>. </p>
   <p> This specification is getting close to moving to the Candidate Recommendation phase under the condition of incorporating the decided resolutions to the <a href="https://github.com/w3c/ServiceWorker/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22Version+1%22">open issues</a>. Apart from addressing these issues, no changes are intended to be added to this specification. Implementers interested in implementing new features should refer to the <a href="https://w3c.github.io/ServiceWorker/">Service Workers Nightly</a> document. </p>
   <p> While a new final Working Draft is likely to be produced before moving to the Candidate Recommendation phase, readers are encouraged to review this document and provide final comments. </p>
   <p></p>
  </div>
  <div data-fill-with="at-risk"></div>
  <nav data-fill-with="table-of-contents" id="toc">
   <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
   <ol class="toc" role="directory">
    <li><a href="#motivations"><span class="secno">1</span> <span class="content">Motivations</span></a>
    <li>
     <a href="#model"><span class="secno">2</span> <span class="content">Model</span></a>
     <ol class="toc">
      <li>
       <a href="#service-worker-concept"><span class="secno">2.1</span> <span class="content">Service Worker</span></a>
       <ol class="toc">
        <li><a href="#service-worker-lifetime"><span class="secno">2.1.1</span> <span class="content">Lifetime</span></a>
       </ol>
      <li>
       <a href="#service-worker-registration-concept"><span class="secno">2.2</span> <span class="content">Service Worker Registration</span></a>
       <ol class="toc">
        <li><a href="#service-worker-registration-lifetime"><span class="secno">2.2.1</span> <span class="content">Lifetime</span></a>
       </ol>
      <li><a href="#service-worker-client-concept"><span class="secno">2.3</span> <span class="content">Service Worker Client</span></a>
      <li><a href="#selection"><span class="secno">2.4</span> <span class="content">Selection and Use</span></a>
      <li><a href="#task-sources"><span class="secno">2.5</span> <span class="content">Task Sources</span></a>
      <li><a href="#user-agent-shutdown"><span class="secno">2.6</span> <span class="content">User Agent Shutdown</span></a>
     </ol>
    <li>
     <a href="#document-context"><span class="secno">3</span> <span class="content">Client Context</span></a>
     <ol class="toc">
      <li>
       <a href="#service-worker-obj"><span class="secno">3.1</span> <span class="content"><code class="idl"><span>ServiceWorker</span></code></span></a>
       <ol class="toc">
        <li><a href="#service-worker-url"><span class="secno">3.1.1</span> <span class="content"><code class="idl"><span>scriptURL</span></code></span></a>
        <li><a href="#service-worker-state"><span class="secno">3.1.2</span> <span class="content"><code class="idl"><span>state</span></code></span></a>
        <li><a href="#service-worker-postmessage"><span class="secno">3.1.3</span> <span class="content"><code class="idl"><span>postMessage(message, transfer)</span></code></span></a>
        <li><a href="#service-worker-event-handler"><span class="secno">3.1.4</span> <span class="content">Event handler</span></a>
       </ol>
      <li>
       <a href="#service-worker-registration-obj"><span class="secno">3.2</span> <span class="content"><code class="idl"><span>ServiceWorkerRegistration</span></code></span></a>
       <ol class="toc">
        <li><a href="#navigator-service-worker-installing"><span class="secno">3.2.1</span> <span class="content"><code class="idl"><span>installing</span></code></span></a>
        <li><a href="#navigator-service-worker-waiting"><span class="secno">3.2.2</span> <span class="content"><code class="idl"><span>waiting</span></code></span></a>
        <li><a href="#navigator-service-worker-active"><span class="secno">3.2.3</span> <span class="content"><code class="idl"><span>active</span></code></span></a>
        <li><a href="#service-worker-registration-scope"><span class="secno">3.2.4</span> <span class="content"><code class="idl"><span>scope</span></code></span></a>
        <li><a href="#service-worker-registration-update"><span class="secno">3.2.5</span> <span class="content"><code class="idl"><span>update()</span></code></span></a>
        <li><a href="#navigator-service-worker-unregister"><span class="secno">3.2.6</span> <span class="content"><code class="idl"><span>unregister()</span></code></span></a>
        <li><a href="#service-worker-registration-event-handler"><span class="secno">3.2.7</span> <span class="content">Event handler</span></a>
       </ol>
      <li><a href="#navigator-service-worker"><span class="secno">3.3</span> <span class="content"><code class="idl"><span>navigator.serviceWorker</span></code></span></a>
      <li>
       <a href="#service-worker-container"><span class="secno">3.4</span> <span class="content"><code class="idl"><span>ServiceWorkerContainer</span></code></span></a>
       <ol class="toc">
        <li><a href="#navigator-service-worker-controller"><span class="secno">3.4.1</span> <span class="content"><code class="idl"><span>controller</span></code></span></a>
        <li><a href="#navigator-service-worker-ready"><span class="secno">3.4.2</span> <span class="content"><code class="idl"><span>ready</span></code></span></a>
        <li><a href="#navigator-service-worker-register"><span class="secno">3.4.3</span> <span class="content"><code class="idl"><span>register(scriptURL, options)</span></code></span></a>
        <li><a href="#navigator-service-worker-getRegistration"><span class="secno">3.4.4</span> <span class="content"><code class="idl"><span>getRegistration(clientURL)</span></code></span></a>
        <li><a href="#navigator-service-worker-getRegistrations"><span class="secno">3.4.5</span> <span class="content"><code class="idl"><span>getRegistrations()</span></code></span></a>
        <li><a href="#navigator-service-worker-startMessages"><span class="secno">3.4.6</span> <span class="content"><code class="idl"><span>startMessages()</span></code></span></a>
        <li><a href="#service-worker-container-event-handlers"><span class="secno">3.4.7</span> <span class="content">Event handlers</span></a>
       </ol>
      <li>
       <a href="#serviceworkermessage-event-section"><span class="secno">3.5</span> <span class="content"><code class="idl"><span>ServiceWorkerMessageEvent</span></code></span></a>
       <ol class="toc">
        <li><a href="#serviceworkermessage-event-data"><span class="secno">3.5.1</span> <span class="content"><code class="idl"><span>event.data</span></code></span></a>
        <li><a href="#serviceworkermessage-event-origin"><span class="secno">3.5.2</span> <span class="content"><code class="idl"><span>event.origin</span></code></span></a>
        <li><a href="#serviceworkermessage-event-lasteventid"><span class="secno">3.5.3</span> <span class="content"><code class="idl"><span>event.lastEventId</span></code></span></a>
        <li><a href="#serviceworkermessage-event-source"><span class="secno">3.5.4</span> <span class="content"><code class="idl"><span>event.source</span></code></span></a>
        <li><a href="#serviceworkermessage-event-ports"><span class="secno">3.5.5</span> <span class="content"><code class="idl"><span>event.ports</span></code></span></a>
       </ol>
      <li><a href="#document-context-events"><span class="secno">3.6</span> <span class="content">Events</span></a>
     </ol>
    <li>
     <a href="#execution-context"><span class="secno">4</span> <span class="content">Execution Context</span></a>
     <ol class="toc">
      <li>
       <a href="#service-worker-global-scope"><span class="secno">4.1</span> <span class="content"><code class="idl"><span>ServiceWorkerGlobalScope</span></code></span></a>
       <ol class="toc">
        <li><a href="#service-worker-global-scope-clients"><span class="secno">4.1.1</span> <span class="content"><code class="idl"><span>clients</span></code></span></a>
        <li><a href="#service-worker-global-scope-registration"><span class="secno">4.1.2</span> <span class="content"><code class="idl"><span>registration</span></code></span></a>
        <li><a href="#service-worker-global-scope-skipwaiting"><span class="secno">4.1.3</span> <span class="content"><code class="idl"><span>skipWaiting()</span></code></span></a>
        <li><a href="#service-worker-global-scope-event-handlers"><span class="secno">4.1.4</span> <span class="content">Event handlers</span></a>
       </ol>
      <li>
       <a href="#client"><span class="secno">4.2</span> <span class="content"><code class="idl"><span>Client</span></code></span></a>
       <ol class="toc">
        <li><a href="#client-url"><span class="secno">4.2.1</span> <span class="content"><code class="idl"><span>url</span></code></span></a>
        <li><a href="#client-frametype"><span class="secno">4.2.2</span> <span class="content"><code class="idl"><span>frameType</span></code></span></a>
        <li><a href="#client-id"><span class="secno">4.2.3</span> <span class="content"><code class="idl"><span>id</span></code></span></a>
        <li><a href="#client-postmessage"><span class="secno">4.2.4</span> <span class="content"><code class="idl"><span>postMessage(message, transfer)</span></code></span></a>
        <li><a href="#client-visibilitystate"><span class="secno">4.2.5</span> <span class="content"><code class="idl"><span>visibilityState</span></code></span></a>
        <li><a href="#client-focused"><span class="secno">4.2.6</span> <span class="content"><code class="idl"><span>focused</span></code></span></a>
        <li><a href="#client-focus"><span class="secno">4.2.7</span> <span class="content"><code class="idl"><span>focus()</span></code></span></a>
        <li><a href="#client-navigate"><span class="secno">4.2.8</span> <span class="content"><code class="idl"><span>navigate(url)</span></code></span></a>
       </ol>
      <li>
       <a href="#clients"><span class="secno">4.3</span> <span class="content"><code class="idl"><span>Clients</span></code></span></a>
       <ol class="toc">
        <li><a href="#clients-get"><span class="secno">4.3.1</span> <span class="content"><code class="idl"><span>get(id)</span></code></span></a>
        <li><a href="#clients-getall"><span class="secno">4.3.2</span> <span class="content"><code class="idl"><span>matchAll(options)</span></code></span></a>
        <li><a href="#clients-openwindow"><span class="secno">4.3.3</span> <span class="content"><code class="idl"><span>openWindow(url)</span></code></span></a>
        <li><a href="#clients-claim"><span class="secno">4.3.4</span> <span class="content"><code class="idl"><span>claim()</span></code></span></a>
       </ol>
      <li>
       <a href="#extendable-event"><span class="secno">4.4</span> <span class="content"><code class="idl"><span>ExtendableEvent</span></code></span></a>
       <ol class="toc">
        <li><a href="#wait-until-method"><span class="secno">4.4.1</span> <span class="content"><code class="idl"><span>event.waitUntil(f)</span></code></span></a>
       </ol>
      <li>
       <a href="#fetch-event-section"><span class="secno">4.5</span> <span class="content"><code class="idl"><span>FetchEvent</span></code></span></a>
       <ol class="toc">
        <li><a href="#fetch-event-request"><span class="secno">4.5.1</span> <span class="content"><code class="idl"><span>event.request</span></code></span></a>
        <li><a href="#fetch-event-clientid"><span class="secno">4.5.2</span> <span class="content"><code class="idl"><span>event.clientId</span></code></span></a>
        <li><a href="#fetch-event-isreload"><span class="secno">4.5.3</span> <span class="content"><code class="idl"><span>event.isReload</span></code></span></a>
        <li><a href="#fetch-event-respondwith"><span class="secno">4.5.4</span> <span class="content"><code class="idl"><span>event.respondWith(r)</span></code></span></a>
       </ol>
      <li>
       <a href="#extendablemessage-event-section"><span class="secno">4.6</span> <span class="content"><code class="idl"><span>ExtendableMessageEvent</span></code></span></a>
       <ol class="toc">
        <li><a href="#extendablemessage-event-data"><span class="secno">4.6.1</span> <span class="content"><code class="idl"><span>event.data</span></code></span></a>
        <li><a href="#extendablemessage-event-origin"><span class="secno">4.6.2</span> <span class="content"><code class="idl"><span>event.origin</span></code></span></a>
        <li><a href="#extendablemessage-event-lasteventid"><span class="secno">4.6.3</span> <span class="content"><code class="idl"><span>event.lastEventId</span></code></span></a>
        <li><a href="#extendablemessage-event-source"><span class="secno">4.6.4</span> <span class="content"><code class="idl"><span>event.source</span></code></span></a>
        <li><a href="#extendablemessage-event-ports"><span class="secno">4.6.5</span> <span class="content"><code class="idl"><span>event.ports</span></code></span></a>
       </ol>
      <li><a href="#execution-context-events"><span class="secno">4.7</span> <span class="content">Events</span></a>
     </ol>
    <li>
     <a href="#cache-objects"><span class="secno">5</span> <span class="content">Caches</span></a>
     <ol class="toc">
      <li><a href="#cache-constructs"><span class="secno">5.1</span> <span class="content">Constructs</span></a>
      <li><a href="#cache-lifetimes"><span class="secno">5.2</span> <span class="content">Understanding Cache Lifetimes</span></a>
      <li>
       <a href="#self-caches"><span class="secno">5.3</span> <span class="content"><code class="idl"><span>self.caches</span></code></span></a>
       <ol class="toc">
        <li><a href="#global-caches"><span class="secno">5.3.1</span> <span class="content"><code class="idl"><span>caches</span></code></span></a>
       </ol>
      <li>
       <a href="#cache"><span class="secno">5.4</span> <span class="content"><code class="idl"><span>Cache</span></code></span></a>
       <ol class="toc">
        <li><a href="#cache-match"><span class="secno">5.4.1</span> <span class="content"><code class="idl"><span>match(request, options)</span></code></span></a>
        <li><a href="#cache-matchall"><span class="secno">5.4.2</span> <span class="content"><code class="idl"><span>matchAll(request, options)</span></code></span></a>
        <li><a href="#cache-add"><span class="secno">5.4.3</span> <span class="content"><code class="idl"><span>add(request)</span></code></span></a>
        <li><a href="#cache-addAll"><span class="secno">5.4.4</span> <span class="content"><code class="idl"><span>addAll(requests)</span></code></span></a>
        <li><a href="#cache-put"><span class="secno">5.4.5</span> <span class="content"><code class="idl"><span>put(request, response)</span></code></span></a>
        <li><a href="#cache-delete"><span class="secno">5.4.6</span> <span class="content"><code class="idl"><span>delete(request, options)</span></code></span></a>
        <li><a href="#cache-keys"><span class="secno">5.4.7</span> <span class="content"><code class="idl"><span>keys(request, options)</span></code></span></a>
       </ol>
      <li>
       <a href="#cache-storage"><span class="secno">5.5</span> <span class="content"><code class="idl"><span>CacheStorage</span></code></span></a>
       <ol class="toc">
        <li><a href="#cache-storage-match"><span class="secno">5.5.1</span> <span class="content"><code class="idl"><span>match(request, options)</span></code></span></a>
        <li><a href="#cache-storage-has"><span class="secno">5.5.2</span> <span class="content"><code class="idl"><span>has(cacheName)</span></code></span></a>
        <li><a href="#cache-storage-open"><span class="secno">5.5.3</span> <span class="content"><code class="idl"><span>open(cacheName)</span></code></span></a>
        <li><a href="#cache-storage-delete"><span class="secno">5.5.4</span> <span class="content"><code class="idl"><span>delete(cacheName)</span></code></span></a>
        <li><a href="#cache-storage-keys"><span class="secno">5.5.5</span> <span class="content"><code class="idl"><span>keys()</span></code></span></a>
       </ol>
     </ol>
    <li>
     <a href="#security-considerations"><span class="secno">6</span> <span class="content">Security Considerations</span></a>
     <ol class="toc">
      <li><a href="#secure-context"><span class="secno">6.1</span> <span class="content">Secure Context</span></a>
      <li><a href="#content-security-policy"><span class="secno">6.2</span> <span class="content">Content Security Policy</span></a>
      <li>
       <a href="#origin-relativity"><span class="secno">6.3</span> <span class="content">Origin Relativity</span></a>
       <ol class="toc">
        <li><a href="#origin-restriction"><span class="secno">6.3.1</span> <span class="content">Origin restriction</span></a>
        <li><a href="#importscripts"><span class="secno">6.3.2</span> <span class="content"><code class="idl"><span>importScripts(urls)</span></code></span></a>
       </ol>
      <li><a href="#cross-origin-resources"><span class="secno">6.4</span> <span class="content">Cross-Origin Resources and CORS</span></a>
      <li><a href="#implementer-concerns"><span class="secno">6.5</span> <span class="content">Implementer Concerns</span></a>
      <li><a href="#privacy"><span class="secno">6.6</span> <span class="content">Privacy</span></a>
     </ol>
    <li><a href="#storage-considerations"><span class="secno">7</span> <span class="content">Storage Considerations</span></a>
    <li>
     <a href="#extensibility"><span class="secno">8</span> <span class="content">Extensibility</span></a>
     <ol class="toc">
      <li><a href="#extension-to-service-worker-registration"><span class="secno">8.1</span> <span class="content">Define API bound to Service Worker Registration</span></a>
      <li><a href="#extension-to-extendable-event"><span class="secno">8.2</span> <span class="content">Define Functional Event</span></a>
      <li><a href="#extension-to-service-worker-global-scope"><span class="secno">8.3</span> <span class="content">Define Event Handler</span></a>
      <li><a href="#request-functional-event-dispatch"><span class="secno">8.4</span> <span class="content">Request Functional Event Dispatch</span></a>
     </ol>
    <li>
     <a href="#algorithms"><span class="secno"></span> <span class="content">Appendix A: Algorithms</span></a>
     <ol class="toc">
      <li><a href="#create-job-algorithm"><span class="secno"></span> <span class="content">Create Job</span></a>
      <li><a href="#schedule-job-algorithm"><span class="secno"></span> <span class="content">Schedule Job</span></a>
      <li><a href="#run-job-algorithm"><span class="secno"></span> <span class="content">Run Job</span></a>
      <li><a href="#finish-job-algorithm"><span class="secno"></span> <span class="content">Finish Job</span></a>
      <li><a href="#resolve-job-promise-algorithm"><span class="secno"></span> <span class="content">Resolve Job Promise</span></a>
      <li><a href="#reject-job-promise-algorithm"><span class="secno"></span> <span class="content">Reject Job Promise</span></a>
      <li><a href="#register-algorithm"><span class="secno"></span> <span class="content">Register</span></a>
      <li><a href="#update-algorithm"><span class="secno"></span> <span class="content">Update</span></a>
      <li><a href="#soft-update-algorithm"><span class="secno"></span> <span class="content">Soft Update</span></a>
      <li><a href="#installation-algorithm"><span class="secno"></span> <span class="content">Install</span></a>
      <li><a href="#activation-algorithm"><span class="secno"></span> <span class="content">Activate</span></a>
      <li><a href="#run-service-worker-algorithm"><span class="secno"></span> <span class="content">Run Service Worker</span></a>
      <li><a href="#terminate-service-worker-algorithm"><span class="secno"></span> <span class="content">Terminate Service Worker</span></a>
      <li><a href="#on-fetch-request-algorithm"><span class="secno"></span> <span class="content">Handle Fetch</span></a>
      <li><a href="#handle-functional-event-algorithm"><span class="secno"></span> <span class="content">Handle Functional Event</span></a>
      <li><a href="#on-client-unload-algorithm"><span class="secno"></span> <span class="content">Handle Service Worker Client Unload</span></a>
      <li><a href="#on-user-agent-shutdown-algorithm"><span class="secno"></span> <span class="content">Handle User Agent Shutdown</span></a>
      <li><a href="#unregister-algorithm"><span class="secno"></span> <span class="content">Unregister</span></a>
      <li><a href="#set-registration-algorithm"><span class="secno"></span> <span class="content">Set Registration</span></a>
      <li><a href="#clear-registration-algorithm"><span class="secno"></span> <span class="content">Clear Registration</span></a>
      <li><a href="#update-registration-state-algorithm"><span class="secno"></span> <span class="content">Update Registration State</span></a>
      <li><a href="#update-state-algorithm"><span class="secno"></span> <span class="content">Update Worker State</span></a>
      <li><a href="#notify-controller-change-algorithm"><span class="secno"></span> <span class="content">Notify Controller Change</span></a>
      <li><a href="#scope-match-algorithm"><span class="secno"></span> <span class="content">Match Service Worker Registration</span></a>
      <li><a href="#get-registration-algorithm"><span class="secno"></span> <span class="content">Get Registration</span></a>
      <li><a href="#get-newest-worker-algorithm"><span class="secno"></span> <span class="content">Get Newest Worker</span></a>
      <li><a href="#create-client-algorithm"><span class="secno"></span> <span class="content">Create Client</span></a>
      <li><a href="#create-windowclient-algorithm"><span class="secno"></span> <span class="content">Create Window Client</span></a>
      <li><a href="#query-cache-algorithm"><span class="secno"></span> <span class="content">Query Cache</span></a>
      <li><a href="#batch-cache-operations-algorithm"><span class="secno"></span> <span class="content">Batch Cache Operations</span></a>
     </ol>
    <li>
     <a href="#extended-http-headers"><span class="secno"></span> <span class="content">Appendix B: Extended HTTP headers</span></a>
     <ol class="toc">
      <li><a href="#service-worker-script-request"><span class="secno"></span> <span class="content">Service Worker Script Request</span></a>
      <li><a href="#service-worker-script-response"><span class="secno"></span> <span class="content">Service Worker Script Response</span></a>
      <li><a href="#syntax"><span class="secno"></span> <span class="content">Syntax</span></a>
     </ol>
    <li><a href="#acknowledgements"><span class="secno">9</span> <span class="content">Acknowledgements</span></a>
    <li>
     <a href="#conformance"><span class="secno"></span> <span class="content">Conformance</span></a>
     <ol class="toc">
      <li><a href="#conventions"><span class="secno"></span> <span class="content">Document conventions</span></a>
      <li><a href="#conformant-algorithms"><span class="secno"></span> <span class="content">Conformant Algorithms</span></a>
     </ol>
    <li>
     <a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
     <ol class="toc">
      <li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
      <li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
     </ol>
    <li>
     <a href="#references"><span class="secno"></span> <span class="content">References</span></a>
     <ol class="toc">
      <li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
      <li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
     </ol>
    <li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a>
    <li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
   </ol>
  </nav>
  <main>
   <section>
    <h2 class="heading settled" data-level="1" id="motivations"><span class="secno">1. </span><span class="content">Motivations</span><a class="self-link" href="#motivations"></a></h2>
    <p><em>This section is non-normative.</em></p>
    <p>Web Applications traditionally assume that the network is reachable. This assumption pervades the platform. HTML documents are loaded over HTTP and traditionally fetch all of their sub-resources via subsequent HTTP requests. This places web content at a disadvantage versus other technology stacks.</p>
    <p>The <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-1">service worker</a> is designed first to redress this balance by providing a Web Worker context, which can be started by a runtime when navigations are about to occur. This event-driven worker is registered against an origin and a path (or pattern), meaning it can be consulted when navigations occur to that location. Events that correspond to network requests are dispatched to the worker and the responses generated by the worker may override default network stack behavior. This puts the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-2">service worker</a>, conceptually, between the network and a document renderer, allowing the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-3">service worker</a> to provide content for documents, even while offline.</p>
    <p>Web developers familiar with previous attempts to solve the offline problem have reported a deficit of flexibility in those solutions. As a result, the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-4">service worker</a> is highly procedural, providing a maximum of flexibility at the price of additional complexity for developers. Part of this complexity arises from the need to keep <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-5">service workers</a> responsive in the face of a single-threaded execution model. As a result, APIs exposed by <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-6">service workers</a> are almost entirely asynchronous, a pattern familiar in other JavaScript contexts but accentuated here by the need to avoid blocking document and resource loading.</p>
    <p>Developers using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#application-cache">HTML5 Application Cache</a> have also <a href="http://alistapart.com/article/application-cache-is-a-douchebag">reported that several attributes</a> of the design contribute to <a href="http://alistapart.com/article/application-cache-is-a-douchebag#section6">unrecoverable errors</a>. A key design principle of the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-7">service worker</a> is that errors should <em>always</em> be recoverable. Many details of the update process of <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-8">service workers</a> are designed to avoid these hazards.</p>
    <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-9">Service workers</a> are started and kept alive by their relationship to events, not documents. This design borrows heavily from developer and vendor experience with <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#shared-workers">Shared Workers</a> and <a href="https://developer.chrome.com/extensions/background_pages">Chrome Background Pages</a>. A key lesson from these systems is the necessity to time-limit the execution of background processing contexts, both to conserve resources and to ensure that background context loss and restart is top-of-mind for developers. As a result, <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-10">service workers</a> bear more than a passing resemblance to <a href="https://developer.chrome.com/extensions/event_pages">Chrome Event Pages</a>, the successor to Background Pages. <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-11">Service workers</a> may be started by user agents <em>without an attached document</em> and may be killed by the user agent at nearly any time. Conceptually, <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-12">service workers</a> can be thought of as Shared Workers that can start, process events, and die without ever handling messages from documents. Developers are advised to keep in mind that <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-13">service workers</a> may be started and killed many times a second.</p>
    <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-14">Service workers</a> are generic, event-driven, time-limited script contexts that run at an origin. These properties make them natural endpoints for a range of runtime services that may outlive the context of a particular document, e.g. handling push notifications, background data synchronization, responding to resource requests from other origins, or receiving centralized updates to expensive-to-calculate data (e.g., geolocation or gyroscope).</p>
   </section>
   <section>
    <h2 class="heading settled" data-level="2" id="model"><span class="secno">2. </span><span class="content">Model</span><a class="self-link" href="#model"></a></h2>
    <section>
     <h3 class="heading settled" data-level="2.1" id="service-worker-concept"><span class="secno">2.1. </span><span class="content">Service Worker</span><a class="self-link" href="#service-worker-concept"></a></h3>
     <p>A <dfn class="dfn-paneled" data-dfn-for="" data-dfn-type="dfn" data-export="" id="dfn-service-worker">service worker</dfn> is a type of <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#workers">web worker</a>. A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-15">service worker</a> executes in the registering <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-1">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-16">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-state">state</dfn>, which is one of <em>parsed</em>, <em>installing</em>, <em>installed</em>, <em>activating</em>, <em>activated</em>, and <em>redundant</em>. It is initially <em>parsed</em>.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-17">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-script-url">script url</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>).</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-18">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-type">type</dfn> which is either "<code>classic</code>" or "<code>module</code>". Unless stated otherwise, it is "<code>classic</code>".</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-19">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-containing-service-worker-registration">containing service worker registration</dfn> (a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-1">service worker registration</a>), which contains itself.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-20">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-service-worker-id">id</dfn> (an opaque string), which uniquely identifies itself during the lifetime of its <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-1">containing service worker registration</a>.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-21">service worker</a> is dispatched a set of <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-lifecycle-events">lifecycle events</dfn>, <a href="#service-worker-global-scope-install-event" id="ref-for-service-worker-global-scope-install-event-1">install</a> and <a href="#service-worker-global-scope-activate-event" id="ref-for-service-worker-global-scope-activate-event-1">activate</a>, and <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-functional-events">functional events</dfn> including <a href="#service-worker-global-scope-fetch-event" id="ref-for-service-worker-global-scope-fetch-event-1">fetch</a>.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-22">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-script-resource">script resource</dfn> (a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-script">script</a>), which represents its own script resource. It is initially set to null. A <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-1">script resource</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-has-ever-been-evaluated-flag">has ever been evaluated flag</dfn>. It is initially unset. A <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-2">script resource</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-https-state">HTTPS state</dfn> which is "<code>none</code>", "<code>deprecated</code>", or "<code>modern</code>". Unless stated otherwise, it is "<code>none</code>".</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-23">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-script-resource-map">script resource map</dfn> which is a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">List</a> of the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} where [[key]] is a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a> and [[value]] is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">response</a>.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-24">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-skip-waiting-flag">skip waiting flag</dfn>. Unless stated otherwise it is unset.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-25">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-imported-scripts-updated-flag">imported scripts updated flag</dfn>. It is initially unset.</p>
     <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-26">service worker</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker" data-dfn-type="dfn" data-export="" id="dfn-set-of-event-types-to-handle">set of event types to handle</dfn> whose element type is an <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-listener">event listener</a>’s event type. It is initially set to null.</p>
     <section>
      <h4 class="heading settled" data-level="2.1.1" id="service-worker-lifetime"><span class="secno">2.1.1. </span><span class="content">Lifetime</span><a class="self-link" href="#service-worker-lifetime"></a></h4>
      <p>The lifetime of a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-27">service worker</a> is tied to the execution lifetime of events and not references held by <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-2">service worker clients</a> to the <code><a href="#service-worker-interface" id="ref-for-service-worker-interface-1">ServiceWorker</a></code> object.</p>
      <p>A user agent <em class="rfc2119" title="MAY">may</em> <a href="#terminate-service-worker-algorithm">terminate</a> <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-28">service workers</a> at any time it:</p>
      <ul>
       <li>Has no event to handle.
       <li>Detects abnormal operation: such as infinite loops and tasks exceeding imposed time limits (if any) while handling the events.
      </ul>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="2.2" id="service-worker-registration-concept"><span class="secno">2.2. </span><span class="content">Service Worker Registration</span><a class="self-link" href="#service-worker-registration-concept"></a></h3>
     <p>A <dfn class="dfn-paneled" data-dfn-for="" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-registration">service worker registration</dfn> is a tuple of a <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-1">scope url</a> and a set of <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-29">service workers</a>, an <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-1">installing worker</a>, a <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-1">waiting worker</a>, and an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-1">active worker</a>. A user agent <em class="rfc2119" title="MAY">may</em> enable many <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-2">service worker registrations</a> at a single origin so long as the <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-2">scope url</a> of the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-3">service worker registration</a> differs. A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-4">service worker registration</a> of an identical <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-3">scope url</a> when one already exists in the user agent causes the existing <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-5">service worker registration</a> to be replaced.</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-6">service worker registration</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-scope-url">scope url</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>).</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-7">service worker registration</a> has an associated <dfn data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-registration-script-url">registering script url<a class="self-link" href="#dfn-registration-script-url"></a></dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>).</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-8">service worker registration</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-installing-worker">installing worker</dfn> (a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-30">service worker</a> or null) whose <a href="#dfn-state" id="ref-for-dfn-state-1">state</a> is <em>installing</em>. It is initially set to null.</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-9">service worker registration</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-waiting-worker">waiting worker</dfn> (a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-31">service worker</a> or null) whose <a href="#dfn-state" id="ref-for-dfn-state-2">state</a> is <em>installed</em>. It is initially set to null.</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-10">service worker registration</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-active-worker">active worker</dfn> (a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-32">service worker</a> or null) whose <a href="#dfn-state" id="ref-for-dfn-state-3">state</a> is either <em>activating</em> or <em>activated</em>. It is initially set to null.</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-11">service worker registration</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-last-update-check-time">last update check time</dfn>. It is initially set to null.</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-12">service worker registration</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-uninstalling-flag">uninstalling flag</dfn>. It is initially unset.</p>
     <p>A <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-13">service worker registration</a> has one or more <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-registration-task-queue">task queues</dfn> that back up the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a> from its <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-2">active worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a>’s corresponding <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queues</a>. (The target task sources for this back up operation are the <a href="#dfn-handle-fetch-task-source" id="ref-for-dfn-handle-fetch-task-source-1">handle fetch task source</a> and the <a href="#dfn-handle-functional-event-task-source" id="ref-for-dfn-handle-functional-event-task-source-1">handle functional event task source</a>.) The user agent dumps the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-3">active worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a> to the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-14">service worker registration</a>’s <a href="#dfn-service-worker-registration-task-queue" id="ref-for-dfn-service-worker-registration-task-queue-1">task queues</a> when the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-4">active worker</a> is <a href="#terminate-service-worker-algorithm">terminated</a> and <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">re-queues those tasks</a> to the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-5">active worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a>’s corresponding <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queues</a> when the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-6">active worker</a> spins off. Unlike the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queues</a> owned by <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loops</a>, the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-15">service worker registration</a>’s <a href="#dfn-service-worker-registration-task-queue" id="ref-for-dfn-service-worker-registration-task-queue-2">task queues</a> are not processed by any <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loops</a> in and of itself.</p>
     <section>
      <h4 class="heading settled" data-level="2.2.1" id="service-worker-registration-lifetime"><span class="secno">2.2.1. </span><span class="content">Lifetime</span><a class="self-link" href="#service-worker-registration-lifetime"></a></h4>
      <p>A user agent <em class="rfc2119" title="MUST">must</em> persistently keep a list of <a href="#register-algorithm">registered</a> <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-16">service worker registrations</a> unless otherwise they are explicitly <a href="#unregister-algorithm">unregistered</a>. A user agent has a <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-1">scope to registration map</a> that stores the entries of the tuple of <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-17">service worker registration</a>’s <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-4">scope url</a> and the corresponding <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-18">service worker registration</a>. The lifetime of <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-19">service worker registrations</a> is beyond that of the <code><a href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-1">ServiceWorkerRegistration</a></code> objects which represent them within the lifetime of their corresponding <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-3">service worker clients</a>.</p>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="2.3" id="service-worker-client-concept"><span class="secno">2.3. </span><span class="content">Service Worker Client</span><a class="self-link" href="#service-worker-client-concept"></a></h3>
     <p>A <dfn class="dfn-paneled" data-dfn-for="" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-client">service worker client</dfn> is a type of <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>.</p>
     <p>A <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-4">service worker client</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker client" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-client-active-worker">active worker</dfn> (an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-7">active worker</a>) which currently <a href="#dfn-control" id="ref-for-dfn-control-1">controls</a> it. It is initially set to null.</p>
     <p>A <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-5">service worker client</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker client" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-client-id">id</dfn> (an opaque string), which uniquely identifies itself during its lifetime. It is initially set to a new unique value when the corresponding <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a> that it represents is created.</p>
     <p>A <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-6">service worker client</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker client" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-client-frame-type">frame type</dfn>, which is one of <em>auxiliary</em>, <em>top-level</em>, <em>nested</em>, and <em>none</em>. Unless stated otherwise it is <em>none</em>. </p>
     <p>A <dfn class="dfn-paneled" data-dfn-for="service worker client" data-dfn-type="dfn" data-noexport="" id="dfn-window-client">window client</dfn> is a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-7">service worker client</a> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> is a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object.</p>
     <p>A <dfn class="dfn-paneled" data-dfn-for="service worker client" data-dfn-type="dfn" data-noexport="" id="dfn-dedicatedworker-client">dedicated worker client</dfn> is a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-8">service worker client</a> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> is a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> object.</p>
     <p>A <dfn class="dfn-paneled" data-dfn-for="service worker client" data-dfn-type="dfn" data-noexport="" id="dfn-sharedworker-client">shared worker client</dfn> is a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-9">service worker client</a> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> is a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object.</p>
     <p>A <dfn class="dfn-paneled" data-dfn-for="service worker client" data-dfn-type="dfn" data-noexport="" id="dfn-worker-client">worker client</dfn> is either a <a href="#dfn-dedicatedworker-client" id="ref-for-dfn-dedicatedworker-client-1">dedicated worker client</a> or a <a href="#dfn-sharedworker-client" id="ref-for-dfn-sharedworker-client-1">shared worker client</a>.</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="2.4" id="selection"><span class="secno">2.4. </span><span class="content">Selection and Use</span><a class="self-link" href="#selection"></a></h3>
     <p>A <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-10">service worker client</a> independently <a href="#dfn-service-worker-registration-selection" id="ref-for-dfn-service-worker-registration-selection-1">selects</a> and <a href="#dfn-use" id="ref-for-dfn-use-1">uses</a> a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-20">service worker registration</a> for its own loading and its subresources. The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-registration-selection">selection</dfn> of a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-21">service worker registration</a>, upon a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</a>, is a process of either <a href="#scope-match-algorithm">matching</a> a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-22">service worker registration</a> from <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-2">scope to registration map</a> or inheriting an existing <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-23">service worker registration</a> from its parent or owner context depending on the request’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>.</p>
     <p>When the request’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a> is not <a data-link-type="dfn" href="https://url.spec.whatwg.org/#is-local">local</a>, a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-11">service worker client</a> <a href="#scope-match-algorithm">matches</a> a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-24">service worker registration</a> from <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-3">scope to registration map</a>. That is, the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-12">service worker client</a> attempts to consult a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-25">service worker registration</a> whose <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-5">scope url</a> <a href="#scope-match-algorithm">matches</a> its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a>.</p>
     <p>When the request’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a> <a data-link-type="dfn" href="https://url.spec.whatwg.org/#is-local">is local</a>, if the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-13">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-browsing-context">responsible browsing context</a> is a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#nested-browsing-context">nested browsing context</a> or the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-14">service worker client</a> is a <a href="#dfn-worker-client" id="ref-for-dfn-worker-client-1">worker client</a>, the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-15">service worker client</a> inherits the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-26">service worker registration</a> from its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#parent-browsing-context">parent browsing context</a>’s environment or one of <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#the-worker&apos;s-documents">the worker’s Documents</a>' environment, respectively, if it exists.</p>
     <p>If the <a href="#dfn-service-worker-registration-selection" id="ref-for-dfn-service-worker-registration-selection-2">selection</a> was successful, the <a href="#dfn-service-worker-registration-selection" id="ref-for-dfn-service-worker-registration-selection-3">selected</a> <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-27">service worker registration</a>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-8">active worker</a> starts to <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-control">control</dfn> the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-16">service worker client</a>. Otherwise, the flow returns to <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> where it falls back to the default behavior. When a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-17">service worker client</a> is <a href="#dfn-control" id="ref-for-dfn-control-2">controlled</a> by an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-9">active worker</a>, it is considered that the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-18">service worker client</a> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-use">using</dfn> the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-10">active worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-2">containing service worker registration</a>.</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="2.5" id="task-sources"><span class="secno">2.5. </span><span class="content">Task Sources</span><a class="self-link" href="#task-sources"></a></h3>
     <p>The following additional <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task sources</a> are used by <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-33">service workers</a>.</p>
     <dl>
      <dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-handle-fetch-task-source">handle fetch task source</dfn>
      <dd>This <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a> is used for <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">dispatching</a> <a href="#service-worker-global-scope-fetch-event" id="ref-for-service-worker-global-scope-fetch-event-2">fetch</a> events to <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-34">service workers</a>.
      <dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-handle-functional-event-task-source">handle functional event task source</dfn>
      <dd>
       This <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a> is used for features that <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">dispatch</a> other <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-1">functional</a> events, e.g. <a href="https://w3c.github.io/push-api/#h-the-push-event">push</a> events, to <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-35">service workers</a>. 
       <p class="note" role="note">A user agent may use a separate task source for each functional event type in order to avoid a head-of-line blocking phenomenon for certain functional events. For instance, a user agent may use a different task source for <a href="http://web-alarms.sysapps.org/#firing-task-event-to-service-worker">task</a> events from other task sources.</p>
     </dl>
    </section>
    <section>
     <h3 class="heading settled" data-level="2.6" id="user-agent-shutdown"><span class="secno">2.6. </span><span class="content">User Agent Shutdown</span><a class="self-link" href="#user-agent-shutdown"></a></h3>
     <p>A user agent <em class="rfc2119" title="MUST">must</em> maintain the state of its stored <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-28">service worker registrations</a> across restarts with the following rules: </p>
     <ul>
      <li>An <a data-link-type="dfn" href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-2">installing worker</a> does not persist but discarded. If the <a data-link-type="dfn" href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-3">installing worker</a> was the only <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-36">service worker</a> for the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-29">service worker registration</a>, the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-30">service worker registration</a> is discarded.
      <li>A <a data-link-type="dfn" href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-2">waiting worker</a> promotes to an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-11">active worker</a>.
     </ul>
     <p></p>
     <p>To attain this, the user agent <em class="rfc2119" title="MUST">must</em> invoke <a href="#on-user-agent-shutdown-algorithm">Handle User Agent Shutdown</a> when it terminates.</p>
    </section>
   </section>
   <section>
    <h2 class="heading settled" data-level="3" id="document-context"><span class="secno">3. </span><span class="content">Client Context</span><a class="self-link" href="#document-context"></a></h2>
    <div class="example" id="example-dd1d6d2d">
     <a class="self-link" href="#example-dd1d6d2d"></a> Bootstrapping with a ServiceWorker: 
<pre class="lang-js highlight"><span class="c1">// scope defaults to the path the script sits in
</span><span class="c1">// "/" in this example
</span>navigator<span class="p">.</span>serviceWorker<span class="p">.</span>register<span class="p">(</span><span class="s2">"/serviceworker.js"</span><span class="p">)</span><span class="p">.</span>then<span class="p">(</span>
  <span class="kd">function</span><span class="p">(</span>registration<span class="p">)</span> <span class="p">{</span>
    console<span class="p">.</span>log<span class="p">(</span><span class="s2">"success!"</span><span class="p">)</span><span class="p">;</span>
    <span class="k">if</span> <span class="p">(</span>registration<span class="p">.</span>installing<span class="p">)</span> <span class="p">{</span>
      registration<span class="p">.</span>installing<span class="p">.</span>postMessage<span class="p">(</span><span class="s2">"Howdy from your installing page."</span><span class="p">)</span><span class="p">;</span>
    <span class="p">}</span>
  <span class="p">}</span><span class="p">,</span>
  <span class="kd">function</span><span class="p">(</span>why<span class="p">)</span> <span class="p">{</span>
    console<span class="p">.</span>error<span class="p">(</span><span class="s2">"Installing the worker failed!:"</span><span class="p">,</span> why<span class="p">)</span><span class="p">;</span>
  <span class="p">}</span><span class="p">)</span><span class="p">;</span>
</pre>
    </div>
    <section>
     <h3 class="heading settled" data-level="3.1" id="service-worker-obj"><span class="secno">3.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-2">ServiceWorker</a></code></span><a class="self-link" href="#service-worker-obj"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-interface" id="ref-for-service-worker-interface-3">ServiceWorker</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString" href="#service-worker-url-attribute" id="ref-for-service-worker-url-attribute-1">scriptURL</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-state-enum" id="ref-for-service-worker-state-enum-1">ServiceWorkerState</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerState" href="#service-worker-state-attribute" id="ref-for-service-worker-state-attribute-1">state</a>;
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#service-worker-postmessage-method" id="ref-for-service-worker-postmessage-method-1">postMessage</a>(<span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="ServiceWorker/postMessage(message, transfer), ServiceWorker/postMessage(message)" data-dfn-type="argument" data-export="" id="dom-serviceworker-postmessage-message-transfer-message">message<a class="self-link" href="#dom-serviceworker-postmessage-message-transfer-message"></a></dfn>, <span class="kt">optional</span> <span class="kt">sequence</span>&lt;<span class="kt">object</span>> <dfn class="nv idl-code" data-dfn-for="ServiceWorker/postMessage(message, transfer), ServiceWorker/postMessage(message)" data-dfn-type="argument" data-export="" id="dom-serviceworker-postmessage-message-transfer-transfer">transfer<a class="self-link" href="#dom-serviceworker-postmessage-message-transfer-transfer"></a></dfn>);

  // event
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-onstatechange-attribute" id="ref-for-service-worker-onstatechange-attribute-1">onstatechange</a>;
};
<a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-4">ServiceWorker</a> <span class="kt">implements</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#abstractworker">AbstractWorker</a>;

<span class="kt">enum</span> <a class="nv idl-code" data-link-type="enum" href="#service-worker-state-enum" id="ref-for-service-worker-state-enum-2">ServiceWorkerState</a> {
  <dfn class="s idl-code" data-dfn-for="ServiceWorkerState" data-dfn-type="enum-value" data-export="" data-lt="&quot;installing&quot;|installing" id="dom-serviceworkerstate-installing">"installing"<a class="self-link" href="#dom-serviceworkerstate-installing"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="ServiceWorkerState" data-dfn-type="enum-value" data-export="" data-lt="&quot;installed&quot;|installed" id="dom-serviceworkerstate-installed">"installed"<a class="self-link" href="#dom-serviceworkerstate-installed"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="ServiceWorkerState" data-dfn-type="enum-value" data-export="" data-lt="&quot;activating&quot;|activating" id="dom-serviceworkerstate-activating">"activating"<a class="self-link" href="#dom-serviceworkerstate-activating"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="ServiceWorkerState" data-dfn-type="enum-value" data-export="" data-lt="&quot;activated&quot;|activated" id="dom-serviceworkerstate-activated">"activated"<a class="self-link" href="#dom-serviceworkerstate-activated"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="ServiceWorkerState" data-dfn-type="enum-value" data-export="" data-lt="&quot;redundant&quot;|redundant" id="dom-serviceworkerstate-redundant">"redundant"<a class="self-link" href="#dom-serviceworkerstate-redundant"></a></dfn>
};
</pre>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorker" data-dfn-type="interface" data-export="" id="service-worker-interface">ServiceWorker</dfn></code> object represents a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-37">service worker</a>. Each <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-5">ServiceWorker</a></code> object is associated with a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-38">service worker</a>. Multiple separate objects implementing the <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-6">ServiceWorker</a></code> interface across documents and workers can all be associated with the same <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-39">service worker</a> simultaneously.</p>
     <p>A <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-7">ServiceWorker</a></code> object has an associated <code class="idl"><a data-link-type="idl" href="#service-worker-state-enum" id="ref-for-service-worker-state-enum-3">ServiceWorkerState</a></code> object which is itself associated with <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-40">service worker</a>’s <a href="#dfn-state" id="ref-for-dfn-state-4">state</a>.</p>
     <section>
      <h4 class="heading settled" data-level="3.1.1" id="service-worker-url"><span class="secno">3.1.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-url-attribute" id="ref-for-service-worker-url-attribute-2">scriptURL</a></code></span><a class="self-link" href="#service-worker-url"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorker" data-dfn-type="attribute" data-export="" id="service-worker-url-attribute"><code>scriptURL</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-41">service worker</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <a href="#dfn-script-url" id="ref-for-dfn-script-url-1">script url</a>.</p>
      <div class="example" id="example-0c9aabd5">
       <a class="self-link" href="#example-0c9aabd5"></a> 
       <p>For example, consider a document created by a navigation to <code>https://example.com/app.html</code> which <a href="#on-fetch-request-algorithm">matches</a> via the following registration call which has been previously executed:</p>
<pre class="lang-js highlight"><span class="c1">// Script on the page https://example.com/app.html
</span>navigator<span class="p">.</span>serviceWorker<span class="p">.</span>register<span class="p">(</span><span class="s2">"/service_worker.js"</span><span class="p">,</span> <span class="p">{</span> scope<span class="o">:</span> <span class="s2">"/"</span> <span class="p">}</span><span class="p">)</span><span class="p">;</span>
</pre>
       <p>The value of <code>navigator.serviceWorker.controller.scriptURL</code> will be "<code>https://example.com/service_worker.js</code>".</p>
      </div>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.1.2" id="service-worker-state"><span class="secno">3.1.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-state-attribute" id="ref-for-service-worker-state-attribute-2">state</a></code></span><a class="self-link" href="#service-worker-state"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorker" data-dfn-type="attribute" data-export="" id="service-worker-state-attribute"><code>state</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value (in <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorker" data-dfn-type="enum" data-export="" id="service-worker-state-enum"><code>ServiceWorkerState</code></dfn> enumeration) to which it was last set.</p>
     </section>
     <section class="algorithm" data-algorithm="service-worker-postmessage">
      <h4 class="heading settled" data-level="3.1.3" id="service-worker-postmessage"><span class="secno">3.1.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-postmessage-method" id="ref-for-service-worker-postmessage-method-2">postMessage(message, transfer)</a></code></span><a class="self-link" href="#service-worker-postmessage"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorker" data-dfn-type="method" data-export="" id="service-worker-postmessage-method"><code>postMessage(<var>message</var>, <var>transfer</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>If the <code class="idl"><a data-link-type="idl" href="#service-worker-state-attribute" id="ref-for-service-worker-state-attribute-3">state</a></code> attribute value of the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a> is "<code>redundant</code>", <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception and abort these steps. 
       <li>Let <var>serviceWorker</var> be the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-42">service worker</a> represented by the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>.
       <li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>serviceWorker</var> as the argument.
       <li>Let <var>destination</var> be the <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-1">ServiceWorkerGlobalScope</a></code> object associated with <var>serviceWorker</var>.
       <li>Let <var>targetRealm</var> be <var>destination</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-global-object-realm">Realm</a>.
       <li>Let <var>incumbentSettings</var> be the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#incumbent-settings-object">incumbent settings object</a>, and <var>incumbentGlobal</var> its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>.
       <li>Let <var>cloneRecord</var> be <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#structuredclonewithtransfer">StructuredCloneWithTransfer</a>(<var>message</var>, <var>transfer</var>, <var>targetRealm</var>). If this <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">rethrow</a> that exception and abort these steps.
       <li>Let <var>clonedMessage</var> be <var>cloneRecord</var>.[[Clone]].
       <li>Let <var>newPorts</var> be a new <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-frozen-array-type">frozen array</a> consisting of all <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a></code> objects in <var>cloneRecord</var>.[[TransferList]], if any, maintaining their relative order.
       <li>
        <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> that runs the following steps: 
        <ol>
         <li>Create an event <var>e</var> that uses the <code class="idl"><a data-link-type="idl" href="#extendablemessage-event-interface" id="ref-for-extendablemessage-event-interface-1">ExtendableMessageEvent</a></code> interface, with the event type <a href="#service-worker-global-scope-message-event" id="ref-for-service-worker-global-scope-message-event-1">message</a>, which does not bubble and is not cancelable.
         <li>Let the <code class="idl"><a data-link-type="idl" href="#extendablemessage-event-data-attribute" id="ref-for-extendablemessage-event-data-attribute-1">data</a></code> attribute of <var>e</var> be initialized to <var>clonedMessage</var>.
         <li>Let the <code class="idl"><a data-link-type="idl" href="#extendablemessage-event-origin-attribute" id="ref-for-extendablemessage-event-origin-attribute-1">origin</a></code> attribute of <var>e</var> be initialized to the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#unicode-serialisation-of-an-origin">Unicode serialization</a> of <var>incumbentSettings</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>.
         <li>If <var>incumbentGlobal</var> is a <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-2">ServiceWorkerGlobalScope</a></code> object, let the <code class="idl"><a data-link-type="idl" href="#extendablemessage-event-source-attribute" id="ref-for-extendablemessage-event-source-attribute-1">source</a></code> attribute of <var>e</var> be initialized to a new <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-8">ServiceWorker</a></code> object that represents <var>incumbentGlobal</var>’s <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-1">service worker</a>.
         <li>Else if <var>incumbentGlobal</var> is a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object, let the <code class="idl"><a data-link-type="idl" href="#extendablemessage-event-source-attribute" id="ref-for-extendablemessage-event-source-attribute-2">source</a></code> attribute of <var>e</var> be initialized to a new <code class="idl"><a data-link-type="idl" href="#window-client-interface" id="ref-for-window-client-interface-1">WindowClient</a></code> object that represents <var>incumbentGlobal</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
         <li>Else, let it be initialized to a new <code class="idl"><a data-link-type="idl" href="#client-interface" id="ref-for-client-interface-1">Client</a></code> object that represents the worker associated with <var>incumbentGlobal</var>.
         <li>Let the <code class="idl"><a data-link-type="idl" href="#extendablemessage-event-ports-attribute" id="ref-for-extendablemessage-event-ports-attribute-1">ports</a></code> attribute of <var>e</var> be initialized to <var>newPorts</var>.
         <li><a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">Dispatch</a> <var>e</var> at <var>destination</var>.
        </ol>
        <p>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">task</a> <em class="rfc2119" title="MUST">must</em> use the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
      </ol>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.1.4" id="service-worker-event-handler"><span class="secno">3.1.4. </span><span class="content">Event handler</span><a class="self-link" href="#service-worker-event-handler"></a></h4>
      <p>The following is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a> (and its corresponding <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event type</a>) that <em class="rfc2119" title="MUST">must</em> be supported, as <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-9">ServiceWorker</a></code> interface:</p>
      <table class="data">
       <thead>
        <tr>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event type</a>
       <tbody>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorker" data-dfn-type="attribute" data-export="" id="service-worker-onstatechange-attribute"><code>onstatechange</code></dfn>
         <td><code><a href="#service-worker-statechange-event" id="ref-for-service-worker-statechange-event-1">statechange</a></code>
      </table>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="3.2" id="service-worker-registration-obj"><span class="secno">3.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-2">ServiceWorkerRegistration</a></code></span><a class="self-link" href="#service-worker-registration-obj"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-3">ServiceWorkerRegistration</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-10">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-registration-installing-attribute" id="ref-for-service-worker-registration-installing-attribute-1">installing</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-11">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-registration-waiting-attribute" id="ref-for-service-worker-registration-waiting-attribute-1">waiting</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-12">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-registration-active-attribute" id="ref-for-service-worker-registration-active-attribute-1">active</a>;

  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString" href="#service-worker-registration-scope-attribute" id="ref-for-service-worker-registration-scope-attribute-1">scope</a>;

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-registration-update-method" id="ref-for-service-worker-registration-update-method-1">update</a>();
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-registration-unregister-method" id="ref-for-service-worker-registration-unregister-method-1">unregister</a>();

  // event
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-registration-onupdatefound-attribute" id="ref-for-service-worker-registration-onupdatefound-attribute-1">onupdatefound</a>;
};
</pre>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="interface" data-export="" id="service-worker-registration-interface">ServiceWorkerRegistration</dfn></code> object represents a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-31">service worker registration</a>. Each <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-4">ServiceWorkerRegistration</a></code> object is associated with a <dfn class="dfn-paneled" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-registration-interface-service-worker-registration">service worker registration</dfn> (a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-32">service worker registration</a>). Multiple separate objects implementing the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-5">ServiceWorkerRegistration</a></code> interface across documents and workers can all be associated with the same <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-33">service worker registration</a> simultaneously.</p>
     <section class="algorithm" data-algorithm="navigator-service-worker-installing">
      <h4 class="heading settled" data-level="3.2.1" id="navigator-service-worker-installing"><span class="secno">3.2.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-registration-installing-attribute" id="ref-for-service-worker-registration-installing-attribute-2">installing</a></code></span><a class="self-link" href="#navigator-service-worker-installing"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="attribute" data-export="" id="service-worker-registration-installing-attribute"><code>installing</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value to which it was last set.</p>
      <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-13">ServiceWorker</a></code> objects returned from this attribute getter that represent the same <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-43">service worker</a> are the same objects.</p>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-waiting">
      <h4 class="heading settled" data-level="3.2.2" id="navigator-service-worker-waiting"><span class="secno">3.2.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-registration-waiting-attribute" id="ref-for-service-worker-registration-waiting-attribute-2">waiting</a></code></span><a class="self-link" href="#navigator-service-worker-waiting"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="attribute" data-export="" id="service-worker-registration-waiting-attribute"><code>waiting</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value to which it was last set.</p>
      <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-14">ServiceWorker</a></code> objects returned from this attribute getter that represent the same <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-44">service worker</a> are the same objects.</p>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-active">
      <h4 class="heading settled" data-level="3.2.3" id="navigator-service-worker-active"><span class="secno">3.2.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-registration-active-attribute" id="ref-for-service-worker-registration-active-attribute-2">active</a></code></span><a class="self-link" href="#navigator-service-worker-active"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="attribute" data-export="" id="service-worker-registration-active-attribute"><code>active</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value to which it was last set.</p>
      <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-15">ServiceWorker</a></code> objects returned from this attribute getter that represent the same <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-45">service worker</a> are the same objects.</p>
     </section>
     <section class="algorithm" data-algorithm="service-worker-registration-scope">
      <h4 class="heading settled" data-level="3.2.4" id="service-worker-registration-scope"><span class="secno">3.2.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-registration-scope-attribute" id="ref-for-service-worker-registration-scope-attribute-2">scope</a></code></span><a class="self-link" href="#service-worker-registration-scope"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="attribute" data-export="" id="service-worker-registration-scope-attribute"><code>scope</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return <a href="#dfn-service-worker-registration-interface-service-worker-registration" id="ref-for-dfn-service-worker-registration-interface-service-worker-registration-1">service worker registration</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-6">scope url</a>.</p>
      <p class="example" id="example-5b08983c"><a class="self-link" href="#example-5b08983c"></a>In the example in section 3.1.1, the value of <code>registration.scope</code>, obtained from <code>navigator.serviceWorker.ready.then(function(registration) { console.log(registration.scope); })</code> for example, will be "<code>https://example.com/</code>".</p>
     </section>
     <section class="algorithm" data-algorithm="service-worker-registration-update">
      <h4 class="heading settled" data-level="3.2.5" id="service-worker-registration-update"><span class="secno">3.2.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-registration-update-method" id="ref-for-service-worker-registration-update-method-2">update()</a></code></span><a class="self-link" href="#service-worker-registration-update"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="method" data-export="" id="service-worker-registration-update-method"><code>update()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>p</var> be a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>Let <var>registration</var> be the <a href="#dfn-service-worker-registration-interface-service-worker-registration" id="ref-for-dfn-service-worker-registration-interface-service-worker-registration-2">service worker registration</a>.
       <li>Let <var>newestWorker</var> be the result of running <a href="#get-newest-worker-algorithm">Get Newest Worker</a> algorithm passing <var>registration</var> as its argument.
       <li>If <var>newestWorker</var> is null, reject <var>p</var> with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception and abort these steps.
       <li>If the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> <var>globalObject</var> is a <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-3">ServiceWorkerGlobalScope</a></code> object, and <var>globalObject</var>’s associated <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-2">service worker</a>’s <a href="#dfn-state" id="ref-for-dfn-state-5">state</a> is <em>installing</em>, reject <var>p</var> with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception and abort these steps.
       <li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>update</em>, <var>registration</var>’s <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-7">scope url</a>, <var>newestWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-2">script url</a>, <var>p</var>, and the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a> <var>client</var>.
       <li>Set <var>job</var>’s <a data-link-type="dfn" href="#dfn-job-worker-type" id="ref-for-dfn-job-worker-type-1">worker type</a> to <var>newestWorker</var>’s <a data-link-type="dfn" href="#dfn-type" id="ref-for-dfn-type-1">type</a>.
       <li>Invoke <a href="#schedule-job-algorithm">Schedule Job</a> with <var>job</var>.
       <li>Return <var>p</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-unregister">
      <h4 class="heading settled" data-level="3.2.6" id="navigator-service-worker-unregister"><span class="secno">3.2.6. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-registration-unregister-method" id="ref-for-service-worker-registration-unregister-method-2">unregister()</a></code></span><a class="self-link" href="#navigator-service-worker-unregister"></a></h4>
      <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="#service-worker-registration-unregister-method" id="ref-for-service-worker-registration-unregister-method-3">unregister()</a></code> method unregisters the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-34">service worker registration</a>. It is important to note that the currently <a href="#dfn-control" id="ref-for-dfn-control-3">controlled</a> <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-19">service worker client</a>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-1">active worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-3">containing service worker registration</a> is effective until all the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-20">service worker clients</a> (including itself) using this <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-35">service worker registration</a> unload. That is, the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-unregister-method" id="ref-for-service-worker-registration-unregister-method-4">unregister()</a></code> method only affects subsequent <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#navigate">navigations</a>.</p>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="method" data-export="" id="service-worker-registration-unregister-method"><code>unregister()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>p</var> be a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>unregister</em>, the <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-8">scope url</a> of the <a href="#dfn-service-worker-registration-interface-service-worker-registration" id="ref-for-dfn-service-worker-registration-interface-service-worker-registration-3">service worker registration</a>, null, <var>p</var>, and the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a> <var>client</var>.
       <li>Invoke <a href="#schedule-job-algorithm">Schedule Job</a> with <var>job</var>.
       <li>Return <var>p</var>.
      </ol>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.2.7" id="service-worker-registration-event-handler"><span class="secno">3.2.7. </span><span class="content">Event handler</span><a class="self-link" href="#service-worker-registration-event-handler"></a></h4>
      <p>The following is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a> (and its corresponding <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event type</a>) that <em class="rfc2119" title="MUST">must</em> be supported, as <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing <code><a href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-6">ServiceWorkerRegistration</a></code> interface:</p>
      <table class="data">
       <thead>
        <tr>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event type</a>
       <tbody>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="attribute" data-export="" id="service-worker-registration-onupdatefound-attribute"><code>onupdatefound</code></dfn>
         <td><code><a href="#service-worker-registration-updatefound-event" id="ref-for-service-worker-registration-updatefound-event-1">updatefound</a></code>
      </table>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="3.3" id="navigator-service-worker"><span class="secno">3.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#navigator-service-worker-attribute" id="ref-for-navigator-service-worker-attribute-1">navigator.serviceWorker</a></code></span><a class="self-link" href="#navigator-service-worker"></a></h3>
<pre class="idl highlight def"><span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-1">ServiceWorkerContainer</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerContainer" href="#navigator-service-worker-attribute" id="ref-for-navigator-service-worker-attribute-2">serviceWorker</a>;
};

<span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/workers.html#workernavigator">WorkerNavigator</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-2">ServiceWorkerContainer</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerContainer" href="#navigator-service-worker-attribute" id="ref-for-navigator-service-worker-attribute-3">serviceWorker</a>;
};
</pre>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Navigator,WorkerNavigator" data-dfn-type="attribute" data-export="" id="navigator-service-worker-attribute"><code>serviceWorker</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-3">ServiceWorkerContainer</a></code> object that is associated with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>.</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="3.4" id="service-worker-container"><span class="secno">3.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-4">ServiceWorkerContainer</a></code></span><a class="self-link" href="#service-worker-container"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-5">ServiceWorkerContainer</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-16">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-container-controller-attribute" id="ref-for-service-worker-container-controller-attribute-1">controller</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-7">ServiceWorkerRegistration</a>> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Promise<ServiceWorkerRegistration>" href="#service-worker-container-ready-attribute" id="ref-for-service-worker-container-ready-attribute-1">ready</a>;

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-8">ServiceWorkerRegistration</a>> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-register-method" id="ref-for-service-worker-container-register-method-1">register</a>(<span class="kt">USVString</span> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerContainer/register(scriptURL, options), ServiceWorkerContainer/register(scriptURL)" data-dfn-type="argument" data-export="" id="dom-serviceworkercontainer-register-scripturl-options-scripturl">scriptURL<a class="self-link" href="#dom-serviceworkercontainer-register-scripturl-options-scripturl"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-serviceworkercontainer-registrationoptions" id="ref-for-dictdef-serviceworkercontainer-registrationoptions-1">RegistrationOptions</a> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerContainer/register(scriptURL, options), ServiceWorkerContainer/register(scriptURL)" data-dfn-type="argument" data-export="" id="dom-serviceworkercontainer-register-scripturl-options-options">options<a class="self-link" href="#dom-serviceworkercontainer-register-scripturl-options-options"></a></dfn>);

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-getregistration-method" id="ref-for-service-worker-container-getregistration-method-1">getRegistration</a>(<span class="kt">optional</span> <span class="kt">USVString</span> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerContainer/getRegistration(clientURL), ServiceWorkerContainer/getRegistration()" data-dfn-type="argument" data-export="" id="dom-serviceworkercontainer-getregistration-clienturl-clienturl">clientURL<a class="self-link" href="#dom-serviceworkercontainer-getregistration-clienturl-clienturl"></a></dfn> = "");
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-9">ServiceWorkerRegistration</a>>> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-getregistrations-method" id="ref-for-service-worker-container-getregistrations-method-1">getRegistrations</a>();

  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-startMessages-method" id="ref-for-service-worker-container-startMessages-method-1">startMessages</a>();


  // events
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-container-oncontrollerchange-attribute" id="ref-for-service-worker-container-oncontrollerchange-attribute-1">oncontrollerchange</a>;
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-container-onmessage-attribute" id="ref-for-service-worker-container-onmessage-attribute-1">onmessage</a>; // event.source of message events is ServiceWorker object
};
</pre>
<pre class="idl highlight def" id="registration-option-list-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="dictionary" data-export="" id="dictdef-serviceworkercontainer-registrationoptions">RegistrationOptions</dfn> {
  <span class="kt">USVString</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="RegistrationOptions" data-dfn-type="dict-member" data-export="" data-type="USVString " id="dom-registrationoptions-scope">scope</dfn>;
  <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#workertype">WorkerType</a> <dfn class="nv idl-code" data-default="&quot;classic&quot;" data-dfn-for="RegistrationOptions" data-dfn-type="dict-member" data-export="" data-type="WorkerType " id="dom-registrationoptions-type">type<a class="self-link" href="#dom-registrationoptions-type"></a></dfn> = "classic";
};
</pre>
     <p>The user agent <em class="rfc2119" title="MUST">must</em> create a <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-6">ServiceWorkerContainer</a></code> object when a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a></code> object or a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#workernavigator">WorkerNavigator</a></code> object is created and associate it with that object.</p>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="interface" data-export="" id="service-worker-container-interface">ServiceWorkerContainer</dfn></code> provides capabilities to register, unregister, and update the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-36">service worker registrations</a>, and provides access to the state of the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-37">service worker registrations</a> and their associated <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-46">service workers</a>.</p>
     <p>A <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-7">ServiceWorkerContainer</a></code> has an associated <dfn class="dfn-paneled" data-dfn-for="ServiceWorkerContainer" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-container-interface-client">service worker client</dfn>, which is a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-21">service worker client</a> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> is associated with the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a></code> object or the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#workernavigator">WorkerNavigator</a></code> object that the <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-8">ServiceWorkerContainer</a></code> is retrieved from.</p>
     <p>A <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-9">ServiceWorkerContainer</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-for="ServiceWorkerContainer" data-dfn-type="dfn" data-noexport="" id="dfn-ready-promise">ready promise</dfn> (a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>). It is initially set to a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.</p>
     <p>A <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-10">ServiceWorkerContainer</a></code> object has a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a> called the <dfn class="dfn-paneled" data-dfn-for="ServiceWorkerContainer" data-dfn-type="dfn" data-noexport="" id="dfn-client-message-queue">client message queue</dfn>, initially empty. A <a data-link-type="dfn" href="#dfn-client-message-queue" id="ref-for-dfn-client-message-queue-1">client message queue</a> can be enabled or disabled, and is initially disabled. When a <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-11">ServiceWorkerContainer</a></code> object’s <a data-link-type="dfn" href="#dfn-client-message-queue" id="ref-for-dfn-client-message-queue-2">client message queue</a> is enabled, the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a> <em class="rfc2119" title="MUST">must</em> use it as one of its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task sources</a>. When the <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-12">ServiceWorkerContainer</a></code> object’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-global">relevant global object</a> is a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object, all <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queued</a> on its <a data-link-type="dfn" href="#dfn-client-message-queue" id="ref-for-dfn-client-message-queue-3">client message queue</a> <em class="rfc2119" title="MUST">must</em> be associated with its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document">responsible document</a>.</p>
     <section class="algorithm" data-algorithm="navigator-service-worker-controller">
      <h4 class="heading settled" data-level="3.4.1" id="navigator-service-worker-controller"><span class="secno">3.4.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-container-controller-attribute" id="ref-for-service-worker-container-controller-attribute-2">controller</a></code></span><a class="self-link" href="#navigator-service-worker-controller"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="attribute" data-export="" id="service-worker-container-controller-attribute"><code>controller</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>client</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-1">service worker client</a>.
       <li>Return the <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-17">ServiceWorker</a></code> object that represents <var>client</var>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-2">active worker</a>.
      </ol>
      <p class="note" role="note"><code class="idl"><a data-link-type="idl" href="#service-worker-container-controller-attribute" id="ref-for-service-worker-container-controller-attribute-3">navigator.serviceWorker.controller</a></code> returns <code>null</code> if the request is a force refresh (shift+refresh). The <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-18">ServiceWorker</a></code> objects returned from this attribute getter that represent the same <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-47">service worker</a> are the same objects.</p>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-ready">
      <h4 class="heading settled" data-level="3.4.2" id="navigator-service-worker-ready"><span class="secno">3.4.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-container-ready-attribute" id="ref-for-service-worker-container-ready-attribute-2">ready</a></code></span><a class="self-link" href="#navigator-service-worker-ready"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="attribute" data-export="" id="service-worker-container-ready-attribute"><code>ready</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>If the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-ready-promise" id="ref-for-dfn-ready-promise-1">ready promise</a> is settled, return the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-ready-promise" id="ref-for-dfn-ready-promise-2">ready promise</a>.
       <li>Let <var>client</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-2">service worker client</a>.
       <li>Let <var>registration</var> be null.
       <li>Let <var>clientURL</var> be <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a>.
       <li>
        Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>
          <em>CheckRegistration</em>: If the result of running <a href="#scope-match-algorithm">Match Service Worker Registration</a> algorithm with <var>clientURL</var> as its argument is not null, then: 
          <ol>
           <li>Set <var>registration</var> to the result value.
          </ol>
         <li>
          Else: 
          <ol>
           <li>Wait until <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-4">scope to registration map</a> has a new entry.
           <li>Jump to the step labeled <em>CheckRegistration</em>.
          </ol>
         <li>
          If <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-12">active worker</a> is null, wait until <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-13">active worker</a> changes. 
          <p class="note" role="note">Implementers should consider this condition is met when the corresponding registration request gets to the step 6 of <a href="#activation-algorithm">Activate</a> algorithm.</p>
         <li>Resolve <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-ready-promise" id="ref-for-dfn-ready-promise-3">ready promise</a> with the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-10">ServiceWorkerRegistration</a></code> object which represents <var>registration</var>.
        </ol>
       <li>Return <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-ready-promise" id="ref-for-dfn-ready-promise-4">ready promise</a>.
      </ol>
      <p class="note" role="note">When the <code><a href="#service-worker-container-ready-attribute" id="ref-for-service-worker-container-ready-attribute-3">ready</a></code> attribute is accessed, the returned <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> will never reject. Instead, it waits until the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolves with a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-38">service worker registration</a> that has an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-14">active worker</a>.</p>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-register">
      <h4 class="heading settled" data-level="3.4.3" id="navigator-service-worker-register"><span class="secno">3.4.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-container-register-method" id="ref-for-service-worker-container-register-method-2">register(scriptURL, options)</a></code></span><a class="self-link" href="#navigator-service-worker-register"></a></h4>
      <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="#service-worker-container-register-method" id="ref-for-service-worker-container-register-method-3">register(scriptURL, options)</a></code> method creates or updates a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-39">service worker registration</a> for the given <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-9">scope url</a>. If successful, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-40">service worker registration</a> ties the provided <var>scriptURL</var> to a <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-10">scope url</a>, which is subsequently used for <a href="#on-fetch-request-algorithm">navigation matching</a>.</p>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="method" data-export="" data-lt="register(scriptURL, options)|register(scriptURL)" id="service-worker-container-register-method"><code>register(<var>scriptURL</var>, <var>options</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>p</var> be a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>Let <var>client</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-3">service worker client</a>.
       <li>Let <var>scriptURL</var> be the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>scriptURL</var> with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url">API base URL</a>.
       <li>If <var>scriptURL</var> is failure, reject <var>p</var> with a <code>TypeError</code> and abort these steps.
       <li>If <var>scriptURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.
       <li>If any of the strings in <var>scriptURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> contains either <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> "<code>%2f</code>" or <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> "<code>%5c</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.
       <li>Let <var>scopeURL</var> be null.
       <li>
        If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-registrationoptions-scope" id="ref-for-dom-registrationoptions-scope-1">scope</a></code> is <a data-link-type="dfn" href="https://www.w3.org/TR/WebIDL/#dfn-present">not present</a>, set <var>scopeURL</var> to the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> a string "<code>./</code>" with <var>scriptURL</var>. 
        <p class="note" role="note">The scope url for the registration is set to the location of the service worker script by default.</p>
       <li>Else, set <var>scopeURL</var> to the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-registrationoptions-scope" id="ref-for-dom-registrationoptions-scope-2">scope</a></code> with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url">API base URL</a>.
       <li>If <var>scopeURL</var> is failure, reject <var>p</var> with a <code>TypeError</code> and abort these steps.
       <li>If <var>scopeURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.
       <li>If any of the strings in <var>scopeURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> contains either <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> "<code>%2f</code>" or <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> "<code>%5c</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.
       <li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>register</em>, <var>scopeURL</var>, <var>scriptURL</var>, <var>p</var>, and <var>client</var>.
       <li>Invoke <a href="#schedule-job-algorithm">Schedule Job</a> with <var>job</var>.
       <li>Return <var>p</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-getRegistration">
      <h4 class="heading settled" data-level="3.4.4" id="navigator-service-worker-getRegistration"><span class="secno">3.4.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-container-getregistration-method" id="ref-for-service-worker-container-getregistration-method-2">getRegistration(clientURL)</a></code></span><a class="self-link" href="#navigator-service-worker-getRegistration"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="method" data-export="" data-lt="getRegistration(clientURL)|getRegistration()" id="service-worker-container-getregistration-method"><code>getRegistration(<var>clientURL</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>client</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-4">service worker client</a>.
       <li>Let <var>clientURL</var> be the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>clientURL</var> with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url">API base URL</a>.
       <li>If <var>clientURL</var> is failure, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
       <li>If the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of <var>clientURL</var> is not <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>, return a <var>promise</var> rejected with a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>registration</var> be the result of running <a href="#scope-match-algorithm">Match Service Worker Registration</a> algorithm with <var>clientURL</var> as its argument.
         <li>
          If <var>registration</var> is not null, then: 
          <ol>
           <li>Resolve <var>promise</var> with the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-11">ServiceWorkerRegistration</a></code> object which represents <var>registration</var>.
          </ol>
         <li>
          Else: 
          <ol>
           <li>Resolve <var>promise</var> with undefined.
          </ol>
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-getRegistrations">
      <h4 class="heading settled" data-level="3.4.5" id="navigator-service-worker-getRegistrations"><span class="secno">3.4.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-container-getregistrations-method" id="ref-for-service-worker-container-getregistrations-method-2">getRegistrations()</a></code></span><a class="self-link" href="#navigator-service-worker-getRegistrations"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="method" data-export="" id="service-worker-container-getregistrations-method"><code>getRegistrations()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>client</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-5">service worker client</a>.
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>array</var> be an empty array.
         <li>
          For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-5">scope to registration map</a>: 
          <ol>
           <li>If the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>entry</var>.[[key]] is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same</a> as <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>, and <var>entry</var>.[[value]]'s <a href="#dfn-uninstalling-flag" id="ref-for-dfn-uninstalling-flag-1">uninstalling flag</a> is unset, add the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-12">ServiceWorkerRegistration</a></code> object associated with <var>entry</var>.[[value]] to the <var>array</var>.
          </ol>
         <li>Resolve <var>promise</var> with <var>array</var>.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="navigator-service-worker-startMessages">
      <h4 class="heading settled" data-level="3.4.6" id="navigator-service-worker-startMessages"><span class="secno">3.4.6. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-container-startMessages-method" id="ref-for-service-worker-container-startMessages-method-2">startMessages()</a></code></span><a class="self-link" href="#navigator-service-worker-startMessages"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="method" data-export="" id="service-worker-container-startMessages-method"><code>startMessages()</code></dfn> method <em class="rfc2119" title="MUST">must</em> enable the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="#dfn-client-message-queue" id="ref-for-dfn-client-message-queue-4">client message queue</a> if it is not enabled.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.4.7" id="service-worker-container-event-handlers"><span class="secno">3.4.7. </span><span class="content">Event handlers</span><a class="self-link" href="#service-worker-container-event-handlers"></a></h4>
      <p>The following are the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handlers</a> (and their corresponding <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event types</a>) that <em class="rfc2119" title="MUST">must</em> be supported, as <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the <a href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-13">ServiceWorkerContainer</a> interface:</p>
      <table class="data">
       <thead>
        <tr>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event type</a>
       <tbody>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="attribute" data-export="" id="service-worker-container-oncontrollerchange-attribute"><code>oncontrollerchange</code></dfn>
         <td><code><a href="#service-worker-container-controllerchange-event" id="ref-for-service-worker-container-controllerchange-event-1">controllerchange</a></code>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="attribute" data-export="" id="service-worker-container-onmessage-attribute"><code>onmessage</code></dfn>
         <td><code><a href="#service-worker-container-message-event" id="ref-for-service-worker-container-message-event-1">message</a></code>
      </table>
      <p>The first time the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#service-worker-container-onmessage-attribute" id="ref-for-service-worker-container-onmessage-attribute-2">onmessage</a> IDL attribute is set, its <a data-link-type="dfn" href="#dfn-client-message-queue" id="ref-for-dfn-client-message-queue-5">client message queue</a> <em class="rfc2119" title="MUST">must</em> be enabled.</p>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="3.5" id="serviceworkermessage-event-section"><span class="secno">3.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-interface" id="ref-for-serviceworkermessage-event-interface-1">ServiceWorkerMessageEvent</a></code></span><a class="self-link" href="#serviceworkermessage-event-section"></a></h3>
<pre class="idl highlight def">[<dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="constructor" data-export="" data-lt="ServiceWorkerMessageEvent(type, eventInitDict)|ServiceWorkerMessageEvent(type)" id="dom-serviceworkermessageevent-serviceworkermessageevent">Constructor<a class="self-link" href="#dom-serviceworkermessageevent-serviceworkermessageevent"></a></dfn>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEvent/ServiceWorkerMessageEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-serviceworkermessageevent-serviceworkermessageevent-type-eventinitdict-type">type<a class="self-link" href="#dom-serviceworkermessageevent-serviceworkermessageevent-type-eventinitdict-type"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-serviceworkermessageevent-serviceworkermessageeventinit" id="ref-for-dictdef-serviceworkermessageevent-serviceworkermessageeventinit-1">ServiceWorkerMessageEventInit</a> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEvent/ServiceWorkerMessageEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-serviceworkermessageevent-serviceworkermessageevent-type-eventinitdict-eventinitdict">eventInitDict<a class="self-link" href="#dom-serviceworkermessageevent-serviceworkermessageevent-type-eventinitdict-eventinitdict"></a></dfn>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#serviceworkermessage-event-interface" id="ref-for-serviceworkermessage-event-interface-2">ServiceWorkerMessageEvent</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#event">Event</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">any</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="any" href="#serviceworkermessage-event-data-attribute" id="ref-for-serviceworkermessage-event-data-attribute-1">data</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#serviceworkermessage-event-origin-attribute" id="ref-for-serviceworkermessage-event-origin-attribute-1">origin</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#serviceworkermessage-event-lasteventid-attribute" id="ref-for-serviceworkermessage-event-lasteventid-attribute-1">lastEventId</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> (<a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-19">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="(ServiceWorker or MessagePort)?" href="#serviceworkermessage-event-source-attribute" id="ref-for-serviceworkermessage-event-source-attribute-1">source</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">FrozenArray</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="FrozenArray<MessagePort>?" href="#serviceworkermessage-event-ports-attribute" id="ref-for-serviceworkermessage-event-ports-attribute-1">ports</a>;
};
</pre>
<pre class="idl highlight def" id="serviceworkermessage-event-init-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="dictionary" data-export="" id="dictdef-serviceworkermessageevent-serviceworkermessageeventinit">ServiceWorkerMessageEventInit</dfn> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
  <span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="any " id="dom-serviceworkermessageeventinit-data">data<a class="self-link" href="#dom-serviceworkermessageeventinit-data"></a></dfn>;
  <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-serviceworkermessageeventinit-origin">origin<a class="self-link" href="#dom-serviceworkermessageeventinit-origin"></a></dfn>;
  <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-serviceworkermessageeventinit-lasteventid">lastEventId<a class="self-link" href="#dom-serviceworkermessageeventinit-lasteventid"></a></dfn>;
  (<a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-20">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="(ServiceWorker or MessagePort)? " id="dom-serviceworkermessageeventinit-source">source<a class="self-link" href="#dom-serviceworkermessageeventinit-source"></a></dfn>;
  <span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <dfn class="nv idl-code" data-dfn-for="ServiceWorkerMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="sequence<MessagePort>? " id="dom-serviceworkermessageeventinit-ports">ports<a class="self-link" href="#dom-serviceworkermessageeventinit-ports"></a></dfn>;
};
</pre>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-48">Service workers</a> define the <a href="#service-worker-container-message-event" id="ref-for-service-worker-container-message-event-2">message</a> event that extends the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/indices.html#event-message">message</a></code> event defined in <a data-link-type="biblio" href="#biblio-html">[HTML]</a> to allow setting a <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-21">ServiceWorker</a></code> object as the source of the message. For the <a href="#service-worker-container-message-event" id="ref-for-service-worker-container-message-event-3">message</a> event, <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-49">service workers</a> use the <code><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="interface" data-export="" id="serviceworkermessage-event-interface">ServiceWorkerMessageEvent</dfn></code> interface.</p>
     <section>
      <h4 class="heading settled" data-level="3.5.1" id="serviceworkermessage-event-data"><span class="secno">3.5.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-data-attribute" id="ref-for-serviceworkermessage-event-data-attribute-2">event.data</a></code></span><a class="self-link" href="#serviceworkermessage-event-data"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="attribute" data-export="" id="serviceworkermessage-event-data-attribute">data</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the message being sent.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.5.2" id="serviceworkermessage-event-origin"><span class="secno">3.5.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-origin-attribute" id="ref-for-serviceworkermessage-event-origin-attribute-2">event.origin</a></code></span><a class="self-link" href="#serviceworkermessage-event-origin"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="attribute" data-export="" id="serviceworkermessage-event-origin-attribute">origin</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to the empty string. It represents the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-50">service worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a> from which the message is sent.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.5.3" id="serviceworkermessage-event-lasteventid"><span class="secno">3.5.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-lasteventid-attribute" id="ref-for-serviceworkermessage-event-lasteventid-attribute-2">event.lastEventId</a></code></span><a class="self-link" href="#serviceworkermessage-event-lasteventid"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="attribute" data-export="" id="serviceworkermessage-event-lasteventid-attribute">lastEventId</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to the empty string.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.5.4" id="serviceworkermessage-event-source"><span class="secno">3.5.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-source-attribute" id="ref-for-serviceworkermessage-event-source-attribute-2">event.source</a></code></span><a class="self-link" href="#serviceworkermessage-event-source"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="attribute" data-export="" id="serviceworkermessage-event-source-attribute">source</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the <code><a href="#service-worker-interface" id="ref-for-service-worker-interface-22">ServiceWorker</a></code> object whose associated <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-51">service worker</a> the message is sent from.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="3.5.5" id="serviceworkermessage-event-ports"><span class="secno">3.5.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-ports-attribute" id="ref-for-serviceworkermessage-event-ports-attribute-2">event.ports</a></code></span><a class="self-link" href="#serviceworkermessage-event-ports"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerMessageEvent" data-dfn-type="attribute" data-export="" id="serviceworkermessage-event-ports-attribute">ports</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a></code> array being sent, if any.</p>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="3.6" id="document-context-events"><span class="secno">3.6. </span><span class="content">Events</span><a class="self-link" href="#document-context-events"></a></h3>
     <p>The following event is dispatched on <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-23">ServiceWorker</a></code> object:</p>
     <table class="data">
      <thead>
       <tr>
        <th>Event name
        <th>Interface
        <th>Dispatched when…
      <tbody>
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorker" data-dfn-type="event" data-export="" id="service-worker-statechange-event"><code>statechange</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#event">Event</a></code>
        <td>The <code class="idl"><a data-link-type="idl" href="#service-worker-state-attribute" id="ref-for-service-worker-state-attribute-4">state</a></code> attribute of the <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-24">ServiceWorker</a></code> object is changed.
     </table>
     <p>The following event is dispatched on <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-13">ServiceWorkerRegistration</a></code> object:</p>
     <table class="data">
      <thead>
       <tr>
        <th>Event name
        <th>Interface
        <th>Dispatched when…
      <tbody>
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerRegistration" data-dfn-type="event" data-export="" id="service-worker-registration-updatefound-event"><code>updatefound</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#event">Event</a></code>
        <td>The <a href="#dfn-service-worker-registration-interface-service-worker-registration" id="ref-for-dfn-service-worker-registration-interface-service-worker-registration-4">service worker registration</a>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-4">installing worker</a> changes. (See step 8 of the <a href="#installation-algorithm">Install</a> algorithm.)
     </table>
     <p>The following events are dispatched on <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-14">ServiceWorkerContainer</a></code> object:</p>
     <table class="data">
      <thead>
       <tr>
        <th>Event name
        <th>Interface
        <th>Dispatched when…
      <tbody>
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="event" data-export="" id="service-worker-container-controllerchange-event"><code>controllerchange</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#event">Event</a></code>
        <td>The <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-6">service worker client</a>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-3">active worker</a> changes. (See step 9.2 of the <a href="#activation-algorithm">Activate</a> algorithm. The <a href="#dfn-skip-waiting-flag" id="ref-for-dfn-skip-waiting-flag-1">skip waiting flag</a> of a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-52">service worker</a> causes <a href="#activation-algorithm">activation</a> of the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-41">service worker registration</a> to occur while <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-22">service worker clients</a> are <a href="#dfn-use" id="ref-for-dfn-use-2">using</a> the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-42">service worker registration</a>, <code class="idl"><a data-link-type="idl" href="#service-worker-container-controller-attribute" id="ref-for-service-worker-container-controller-attribute-4">navigator.serviceWorker.controller</a></code> immediately reflects the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-15">active worker</a> as the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-53">service worker</a> that <a href="#dfn-control" id="ref-for-dfn-control-4">controls</a> the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-23">service worker client</a>.)
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerContainer" data-dfn-type="event" data-export="" id="service-worker-container-message-event"><code>message</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-interface" id="ref-for-serviceworkermessage-event-interface-3">ServiceWorkerMessageEvent</a></code>
        <td>When it receives a message.
     </table>
    </section>
   </section>
   <section>
    <h2 class="heading settled" data-level="4" id="execution-context"><span class="secno">4. </span><span class="content">Execution Context</span><a class="self-link" href="#execution-context"></a></h2>
    <div class="example" id="example-7fd0ecd9">
     <a class="self-link" href="#example-7fd0ecd9"></a> Serving Cached Resources: 
<pre class="lang-js highlight"><span class="c1">// caching.js
</span><span class="k">this</span><span class="p">.</span>addEventListener<span class="p">(</span><span class="s2">"install"</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span>e<span class="p">)</span> <span class="p">{</span>
  e<span class="p">.</span>waitUntil<span class="p">(</span>
    <span class="c1">// Open a cache of resources.
</span>    caches<span class="p">.</span>open<span class="p">(</span><span class="s2">"shell-v1"</span><span class="p">)</span><span class="p">.</span>then<span class="p">(</span><span class="kd">function</span><span class="p">(</span>cache<span class="p">)</span> <span class="p">{</span>
      <span class="c1">// Begins the process of fetching them.
</span>      <span class="c1">// The coast is only clear when all the resources are ready.
</span>      <span class="k">return</span> cache<span class="p">.</span>addAll<span class="p">(</span><span class="p">[</span>
        <span class="s2">"/app.html"</span><span class="p">,</span>
        <span class="s2">"/assets/v1/base.css"</span><span class="p">,</span>
        <span class="s2">"/assets/v1/app.js"</span><span class="p">,</span>
        <span class="s2">"/assets/v1/logo.png"</span><span class="p">,</span>
        <span class="s2">"/assets/v1/intro_video.webm"</span>
      <span class="p">]</span><span class="p">)</span><span class="p">;</span>
    <span class="p">}</span><span class="p">)</span>
  <span class="p">)</span><span class="p">;</span>
<span class="p">}</span><span class="p">)</span><span class="p">;</span>

<span class="k">this</span><span class="p">.</span>addEventListener<span class="p">(</span><span class="s2">"fetch"</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span>e<span class="p">)</span> <span class="p">{</span>
  <span class="c1">// No "fetch" events are dispatched to the service worker until it
</span>  <span class="c1">// successfully installs and activates.
</span>
  <span class="c1">// All operations on caches are async, including matching URLs, so we use
</span>  <span class="c1">// promises heavily. e.respondWith() even takes promises to enable this:
</span>  e<span class="p">.</span>respondWith<span class="p">(</span>
    caches<span class="p">.</span>match<span class="p">(</span>e<span class="p">.</span>request<span class="p">)</span><span class="p">.</span>then<span class="p">(</span><span class="kd">function</span><span class="p">(</span>response<span class="p">)</span> <span class="p">{</span>
      <span class="k">return</span> response <span class="o">||</span> fetch<span class="p">(</span>e<span class="p">.</span>request<span class="p">)</span><span class="p">;</span>
    <span class="p">}</span><span class="p">)</span><span class="p">.</span><span class="k">catch</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="p">)</span> <span class="p">{</span>
      <span class="k">return</span> caches<span class="p">.</span>match<span class="p">(</span><span class="s2">"/fallback.html"</span><span class="p">)</span><span class="p">;</span>
    <span class="p">}</span><span class="p">)</span>
  <span class="p">)</span><span class="p">;</span>
<span class="p">}</span><span class="p">)</span><span class="p">;</span>
</pre>
    </div>
    <section>
     <h3 class="heading settled" data-level="4.1" id="service-worker-global-scope"><span class="secno">4.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-4">ServiceWorkerGlobalScope</a></code></span><a class="self-link" href="#service-worker-global-scope"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Global">Global</a>=(<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#worker">Worker</a>,<a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-25">ServiceWorker</a>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-5">ServiceWorkerGlobalScope</a> : <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#workerglobalscope">WorkerGlobalScope</a> {
  // A container for a list of Client objects that correspond to
  // browsing contexts (or shared workers) that are on the origin of this SW
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#clients-interface" id="ref-for-clients-interface-1">Clients</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Clients" href="#service-worker-global-scope-clients-attribute" id="ref-for-service-worker-global-scope-clients-attribute-1">clients</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-14">ServiceWorkerRegistration</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerRegistration" href="#service-worker-global-scope-scope-attribute" id="ref-for-service-worker-global-scope-scope-attribute-1">registration</a>;

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-global-scope-skipwaiting-method" id="ref-for-service-worker-global-scope-skipwaiting-method-1">skipWaiting</a>();

  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-oninstall-attribute" id="ref-for-service-worker-global-scope-oninstall-attribute-1">oninstall</a>;
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-onactivate-attribute" id="ref-for-service-worker-global-scope-onactivate-attribute-1">onactivate</a>;
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-onfetch-attribute" id="ref-for-service-worker-global-scope-onfetch-attribute-1">onfetch</a>;

  // event
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-onmessage-attribute" id="ref-for-service-worker-global-scope-onmessage-attribute-1">onmessage</a>; // event.source of the message events is Client object
};
</pre>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="interface" data-export="" id="service-worker-global-scope-interface">ServiceWorkerGlobalScope</dfn></code> object represents the global execution context of a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-54">service worker</a>. A <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-6">ServiceWorkerGlobalScope</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-global-scope-service-worker">service worker</dfn> (a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-55">service worker</a>).</p>
     <p class="note" role="note"><code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-7">ServiceWorkerGlobalScope</a></code> object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully <a href="#navigator-service-worker-register">registered</a>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-56">service worker</a> is started, kept alive and killed by their relationship to events, not <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-24">service worker clients</a>. Any type of synchronous requests must not be initiated inside of a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-57">service worker</a>.</p>
     <section>
      <h4 class="heading settled" data-level="4.1.1" id="service-worker-global-scope-clients"><span class="secno">4.1.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-clients-attribute" id="ref-for-service-worker-global-scope-clients-attribute-2">clients</a></code></span><a class="self-link" href="#service-worker-global-scope-clients"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="attribute" data-export="" id="service-worker-global-scope-clients-attribute"><code>clients</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the <code class="idl"><a data-link-type="idl" href="#clients-interface" id="ref-for-clients-interface-2">Clients</a></code> object that is associated with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.1.2" id="service-worker-global-scope-registration"><span class="secno">4.1.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-scope-attribute" id="ref-for-service-worker-global-scope-scope-attribute-2">registration</a></code></span><a class="self-link" href="#service-worker-global-scope-registration"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="attribute" data-export="" id="service-worker-global-scope-scope-attribute"><code>registration</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-15">ServiceWorkerRegistration</a></code> object that represents the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-3">service worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-4">containing service worker registration</a>.</p>
     </section>
     <section class="algorithm" data-algorithm="service-worker-global-scope-skipwaiting">
      <h4 class="heading settled" data-level="4.1.3" id="service-worker-global-scope-skipwaiting"><span class="secno">4.1.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-skipwaiting-method" id="ref-for-service-worker-global-scope-skipwaiting-method-2">skipWaiting()</a></code></span><a class="self-link" href="#service-worker-global-scope-skipwaiting"></a></h4>
      <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-skipwaiting-method" id="ref-for-service-worker-global-scope-skipwaiting-method-3">skipWaiting()</a></code> method allows this <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-58">service worker</a> to progress from the <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-5">registration</a>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-3">waiting</a> position to <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-16">active</a> even while <a href="#service-worker-client-concept">service worker clients</a> are <a href="#dfn-use" id="ref-for-dfn-use-3">using</a> the <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-6">registration</a>.</p>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="method" data-export="" id="service-worker-global-scope-skipwaiting-method"><code>skipWaiting()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Set <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-59">service worker</a>’s <a href="#dfn-skip-waiting-flag" id="ref-for-dfn-skip-waiting-flag-2">skip waiting flag</a>
         <li>
          If <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-60">service worker</a>’s <a href="#dfn-state" id="ref-for-dfn-state-6">state</a> is <em>installed</em>, then: 
          <ol>
           <li>Run <a href="#activation-algorithm">Activate</a> algorithm passing <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-61">service worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-7">registration</a> as the argument.
          </ol>
         <li>Resolve <var>promise</var> with undefined.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.1.4" id="service-worker-global-scope-event-handlers"><span class="secno">4.1.4. </span><span class="content">Event handlers</span><a class="self-link" href="#service-worker-global-scope-event-handlers"></a></h4>
      <p>The following are the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handlers</a> (and their corresponding <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event types</a>) that <em class="rfc2119" title="MUST">must</em> be supported, as <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the <a href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-8">ServiceWorkerGlobalScope</a> interface:</p>
      <table class="data">
       <thead>
        <tr>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a>
         <th><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event type</a>
       <tbody>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="attribute" data-export="" id="service-worker-global-scope-oninstall-attribute"><code>oninstall</code></dfn>
         <td><code><a href="#service-worker-global-scope-install-event" id="ref-for-service-worker-global-scope-install-event-2">install</a></code>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="attribute" data-export="" id="service-worker-global-scope-onactivate-attribute"><code>onactivate</code></dfn>
         <td><code><a href="#service-worker-global-scope-activate-event" id="ref-for-service-worker-global-scope-activate-event-2">activate</a></code>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="attribute" data-export="" id="service-worker-global-scope-onfetch-attribute"><code>onfetch</code></dfn>
         <td><code><a href="#service-worker-global-scope-fetch-event" id="ref-for-service-worker-global-scope-fetch-event-3">fetch</a></code>
        <tr>
         <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="attribute" data-export="" id="service-worker-global-scope-onmessage-attribute"><code>onmessage</code></dfn>
         <td><code><a href="#service-worker-global-scope-message-event" id="ref-for-service-worker-global-scope-message-event-2">message</a></code>
      </table>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="4.2" id="client"><span class="secno">4.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-interface" id="ref-for-client-interface-2">Client</a></code></span><a class="self-link" href="#client"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#client-interface" id="ref-for-client-interface-3">Client</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString" href="#client-url-attribute" id="ref-for-client-url-attribute-1">url</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#contextframetype-enum" id="ref-for-contextframetype-enum-1">FrameType</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="FrameType" href="#client-frametype-attribute" id="ref-for-client-frametype-attribute-1">frameType</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#client-id-attribute" id="ref-for-client-id-attribute-1">id</a>;
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#client-postmessage-method" id="ref-for-client-postmessage-method-1">postMessage</a>(<span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="Client/postMessage(message, transfer), Client/postMessage(message)" data-dfn-type="argument" data-export="" id="dom-client-postmessage-message-transfer-message">message<a class="self-link" href="#dom-client-postmessage-message-transfer-message"></a></dfn>, <span class="kt">optional</span> <span class="kt">sequence</span>&lt;<span class="kt">object</span>> <dfn class="nv idl-code" data-dfn-for="Client/postMessage(message, transfer), Client/postMessage(message)" data-dfn-type="argument" data-export="" id="dom-client-postmessage-message-transfer-transfer">transfer<a class="self-link" href="#dom-client-postmessage-message-transfer-transfer"></a></dfn>);
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#window-client-interface" id="ref-for-window-client-interface-2">WindowClient</a> : <a class="n" data-link-type="idl-name" href="#client-interface" id="ref-for-client-interface-4">Client</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/page-visibility/#VisibilityState">VisibilityState</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="VisibilityState" href="#client-visibilitystate-attribute" id="ref-for-client-visibilitystate-attribute-1">visibilityState</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="#client-focused-attribute" id="ref-for-client-focused-attribute-1">focused</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#window-client-interface" id="ref-for-window-client-interface-3">WindowClient</a>> <a class="nv idl-code" data-link-type="method" href="#client-focus-method" id="ref-for-client-focus-method-1">focus</a>();
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#window-client-interface" id="ref-for-window-client-interface-4">WindowClient</a>> <a class="nv idl-code" data-link-type="method" href="#client-navigate-method" id="ref-for-client-navigate-method-1">navigate</a>(<span class="kt">USVString</span> <dfn class="nv idl-code" data-dfn-for="WindowClient/navigate(url)" data-dfn-type="argument" data-export="" id="dom-windowclient-navigate-url-url">url<a class="self-link" href="#dom-windowclient-navigate-url-url"></a></dfn>);
};

<span class="kt">enum</span> <a class="nv idl-code" data-link-type="enum" href="#contextframetype-enum" id="ref-for-contextframetype-enum-2">FrameType</a> {
  <dfn class="s idl-code" data-dfn-for="FrameType" data-dfn-type="enum-value" data-export="" data-lt="&quot;auxiliary&quot;|auxiliary" id="dom-frametype-auxiliary">"auxiliary"<a class="self-link" href="#dom-frametype-auxiliary"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="FrameType" data-dfn-type="enum-value" data-export="" data-lt="&quot;top-level&quot;|top-level" id="dom-frametype-top-level">"top-level"<a class="self-link" href="#dom-frametype-top-level"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="FrameType" data-dfn-type="enum-value" data-export="" data-lt="&quot;nested&quot;|nested" id="dom-frametype-nested">"nested"<a class="self-link" href="#dom-frametype-nested"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="FrameType" data-dfn-type="enum-value" data-export="" data-lt="&quot;none&quot;|none" id="dom-frametype-none">"none"<a class="self-link" href="#dom-frametype-none"></a></dfn>
};
</pre>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export="" id="client-interface">Client</dfn></code> object has an associated <dfn class="dfn-paneled" data-dfn-for="Client" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-client-client">service worker client</dfn> (a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-25">service worker client</a>).</p>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export="" id="window-client-interface">WindowClient</dfn></code> object has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-client-visibilitystate">visibility state</dfn>, which is one of <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.</p>
     <p>A <code class="idl"><a data-link-type="idl" href="#window-client-interface" id="ref-for-window-client-interface-5">WindowClient</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-service-worker-client-focusstate">focus state</dfn>, which is either true or false (initially false).</p>
     <section>
      <h4 class="heading settled" data-level="4.2.1" id="client-url"><span class="secno">4.2.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-url-attribute" id="ref-for-client-url-attribute-2">url</a></code></span><a class="self-link" href="#client-url"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Client" data-dfn-type="attribute" data-export="" id="client-url-attribute"><code>url</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-1">service worker client</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a>.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.2.2" id="client-frametype"><span class="secno">4.2.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-frametype-attribute" id="ref-for-client-frametype-attribute-2">frameType</a></code></span><a class="self-link" href="#client-frametype"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Client" data-dfn-type="attribute" data-export="" id="client-frametype-attribute"><code>frameType</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value (in <dfn class="dfn-paneled idl-code" data-dfn-type="enum" data-export="" id="contextframetype-enum"><code>FrameType</code></dfn> enumeration) corresponding to the first matching statement, switching on <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-2">service worker client</a>’s <a href="#dfn-service-worker-client-frame-type" id="ref-for-dfn-service-worker-client-frame-type-1">frame type</a>:</p>
      <dl>
       <dt><em>auxiliary</em>
       <dd>
        "<code>auxiliary</code>" 
        <p class="note" role="note">The <a href="#dfn-window-client" id="ref-for-dfn-window-client-1">window client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a> is an <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#auxiliary-browsing-context">auxiliary browsing context</a>.</p>
       <dt><em>top-level</em>
       <dd>
        "<code>top-level</code>" 
        <p class="note" role="note">The <a href="#dfn-window-client" id="ref-for-dfn-window-client-2">window client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a> is a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#top-level-browsing-context">top-level browsing context</a>.</p>
       <dt><em>nested</em>
       <dd>
        "<code>nested</code>" 
        <p class="note" role="note">The <a href="#dfn-window-client" id="ref-for-dfn-window-client-3">window client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a> is a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#nested-browsing-context">nested browsing context</a>.</p>
       <dt><em>none</em>
       <dd>"<code>none</code>"
      </dl>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.2.3" id="client-id"><span class="secno">4.2.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-id-attribute" id="ref-for-client-id-attribute-2">id</a></code></span><a class="self-link" href="#client-id"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Client" data-dfn-type="attribute" data-export="" id="client-id-attribute"><code>id</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return its associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-3">service worker client</a>’s <a href="#dfn-service-worker-client-id" id="ref-for-dfn-service-worker-client-id-1">id</a>.</p>
     </section>
     <section class="algorithm" data-algorithm="client-postmessage">
      <h4 class="heading settled" data-level="4.2.4" id="client-postmessage"><span class="secno">4.2.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-postmessage-method" id="ref-for-client-postmessage-method-2">postMessage(message, transfer)</a></code></span><a class="self-link" href="#client-postmessage"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Client" data-dfn-type="method" data-export="" data-lt="postMessage(message, transfer)|postMessage(message)" id="client-postmessage-method"><code>postMessage(<var>message</var>, <var>transfer</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>sourceSettings</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>.
       <li>Let <var>destination</var> be the <code class="idl"><a data-link-type="idl" href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-15">ServiceWorkerContainer</a></code> object whose <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-7">service worker client</a> is the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-4">service worker client</a>.
       <li>If <var>destination</var> is null, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception.
       <li>Let <var>targetRealm</var> be <var>destination</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-realm">relevant Realm</a>.
       <li>Let <var>cloneRecord</var> be <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#structuredclonewithtransfer">StructuredCloneWithTransfer</a>(<var>message</var>, <var>transfer</var>, <var>targetRealm</var>). If this <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">rethrow</a> that exception and abort these steps.
       <li>Let <var>clonedMessage</var> be <var>cloneRecord</var>.[[Clone]].
       <li>Let <var>newPorts</var> be a new <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-frozen-array-type">frozen array</a> consisting of all <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a></code> objects in <var>cloneRecord</var>.[[TransferList]], if any, maintaining their relative order.
       <li>
        Add a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">task</a> that runs the following steps to <var>destination</var>’s <a data-link-type="dfn" href="#dfn-client-message-queue" id="ref-for-dfn-client-message-queue-6">client message queue</a>: 
        <ol>
         <li>Create an event <var>e</var> that uses the <code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-interface" id="ref-for-serviceworkermessage-event-interface-4">ServiceWorkerMessageEvent</a></code> interface, with the event type <a href="#service-worker-container-message-event" id="ref-for-service-worker-container-message-event-4">message</a>, which does not bubble and is not cancelable.
         <li>Let the <code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-data-attribute" id="ref-for-serviceworkermessage-event-data-attribute-3">data</a></code> attribute of <var>e</var> be initialized to <var>clonedMessage</var>.
         <li>Let the <code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-origin-attribute" id="ref-for-serviceworkermessage-event-origin-attribute-3">origin</a></code> attribute of <var>e</var> be initialized to the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#unicode-serialisation-of-an-origin">Unicode serialization</a> of <var>sourceSettings</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>.
         <li>Let the <code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-source-attribute" id="ref-for-serviceworkermessage-event-source-attribute-3">source</a></code> attribute of <var>e</var> be initialized to a <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-26">ServiceWorker</a></code> object, which represents the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-4">service worker</a> associated with <var>sourceSettings</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>.
         <li>Let the <code class="idl"><a data-link-type="idl" href="#serviceworkermessage-event-ports-attribute" id="ref-for-serviceworkermessage-event-ports-attribute-3">ports</a></code> attribute of <var>e</var> be initialized to <var>newPorts</var>.
         <li><a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">Dispatch</a> <var>e</var> at <var>destination</var>.
        </ol>
      </ol>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.2.5" id="client-visibilitystate"><span class="secno">4.2.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-visibilitystate-attribute" id="ref-for-client-visibilitystate-attribute-2">visibilityState</a></code></span><a class="self-link" href="#client-visibilitystate"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="WindowClient" data-dfn-type="attribute" data-export="" id="client-visibilitystate-attribute"><code>visibilityState</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-client-visibilitystate" id="ref-for-dfn-service-worker-client-visibilitystate-1">visibility state</a>.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.2.6" id="client-focused"><span class="secno">4.2.6. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-focused-attribute" id="ref-for-client-focused-attribute-2">focused</a></code></span><a class="self-link" href="#client-focused"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="WindowClient" data-dfn-type="attribute" data-export="" id="client-focused-attribute"><code>focused</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-service-worker-client-focusstate" id="ref-for-dfn-service-worker-client-focusstate-1">focus state</a>.</p>
     </section>
     <section class="algorithm" data-algorithm="client-focus">
      <h4 class="heading settled" data-level="4.2.7" id="client-focus"><span class="secno">4.2.7. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-focus-method" id="ref-for-client-focus-method-2">focus()</a></code></span><a class="self-link" href="#client-focus"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="WindowClient" data-dfn-type="method" data-export="" id="client-focus-method"><code>focus()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>If this algorithm is not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#triggered-by-user-activation">triggered by user activation</a>, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidaccesserror">InvalidAccessError</a></code>" exception.
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>browsingContext</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-5">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
         <li>Let <var>visibilityState</var> be null.
         <li>Let <var>focusState</var> be null.
         <li>
          <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps on the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-6">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#user-interaction-task-source">user interaction task source</a>: 
          <ol>
           <li>Run the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps">focusing steps</a> with <var>browsingContext</var>.
           <li>Set <var>visibilityState</var> to <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
           <li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
          </ol>
         <li>Wait for <var>task</var> to have executed.
         <li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-7">service worker client</a>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
         <li>If <var>windowClient</var>’s <a href="#dfn-service-worker-client-focusstate" id="ref-for-dfn-service-worker-client-focusstate-2">focus state</a> is true, resolve <var>promise</var> with <var>windowClient</var>.
         <li>Else, reject <var>promise</var> with a <code>TypeError</code>.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="client-navigate">
      <h4 class="heading settled" data-level="4.2.8" id="client-navigate"><span class="secno">4.2.8. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#client-navigate-method" id="ref-for-client-navigate-method-2">navigate(url)</a></code></span><a class="self-link" href="#client-navigate"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="WindowClient" data-dfn-type="method" data-export="" data-lt="navigate(url)" id="client-navigate-method"><code>navigate()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>url</var> be the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>url</var> with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url">API base URL</a>.
       <li>If <var>url</var> is failure, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
       <li>If <var>url</var> is <code><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#about:blank">about:blank</a></code>, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
       <li>If the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-8">service worker client</a>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-4">active worker</a> is not the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-global">relevant global object</a>’s <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-5">service worker</a>, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>browsingContext</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-9">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
         <li>If <var>browsingContext</var> has <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#discard-a-document">discarded</a> its <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#document">Document</a></code>, reject <var>promise</var> with a <code>TypeError</code> and abort these steps.
         <li>Let <var>navigateFailed</var> to false.
         <li>Let <var>visibilityState</var> be null.
         <li>Let <var>focusState</var> be null.
         <li>
          <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps on the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s associated <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-10">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#user-interaction-task-source">user interaction task source</a>: 
          <ol>
           <li><em>HandleNavigate</em>: <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#navigate">Navigate</a> <var>browsingContext</var> to <var>url</var> with <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#replacement-enabled">replacement enabled</a> and <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#exceptions-enabled">exceptions enabled</a>. The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#source-browsing-context">source browsing context</a> must be <var>browsingContext</var>.
           <li>If the algorithm steps invoked in the step labeled <em>HandleNavigate</em> <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, set <var>navigateFailed</var> to true.
           <li>Set <var>visibilityState</var> to <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
           <li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
          </ol>
         <li>Wait for <var>task</var> to have executed (including its asynchronous steps).
         <li>If <var>navigateFailed</var> is true, reject <var>promise</var> with a <code>TypeError</code> and abort these steps.
         <li>
          If <var>browsingContext</var>’s <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> is not the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same</a> as the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-6">service worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>, then: 
          <ol>
           <li>Resolve <var>promise</var> with null.
           <li>Abort these steps.
          </ol>
         <li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>browsingContext</var>’s <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
         <li>Resolve <var>promise</var> with <var>windowClient</var>.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="4.3" id="clients"><span class="secno">4.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#clients-interface" id="ref-for-clients-interface-3">Clients</a></code></span><a class="self-link" href="#clients"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#clients-interface" id="ref-for-clients-interface-4">Clients</a> {
  // The objects returned will be new instances every time
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#clients-get-method" id="ref-for-clients-get-method-1">get</a>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Clients/get(id)" data-dfn-type="argument" data-export="" id="dom-clients-get-id-id">id<a class="self-link" href="#dom-clients-get-id-id"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="#client-interface" id="ref-for-client-interface-5">Client</a>>> <a class="nv idl-code" data-link-type="method" href="#clients-matchall-method" id="ref-for-clients-matchall-method-1">matchAll</a>(<span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-clients-clientqueryoptions" id="ref-for-dictdef-clients-clientqueryoptions-1">ClientQueryOptions</a> <dfn class="nv idl-code" data-dfn-for="Clients/matchAll(options), Clients/matchAll()" data-dfn-type="argument" data-export="" id="dom-clients-matchall-options-options">options<a class="self-link" href="#dom-clients-matchall-options-options"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#window-client-interface" id="ref-for-window-client-interface-6">WindowClient</a>?> <a class="nv idl-code" data-link-type="method" href="#clients-openwindow-method" id="ref-for-clients-openwindow-method-1">openWindow</a>(<span class="kt">USVString</span> <dfn class="nv idl-code" data-dfn-for="Clients/openWindow(url)" data-dfn-type="argument" data-export="" id="dom-clients-openwindow-url-url">url<a class="self-link" href="#dom-clients-openwindow-url-url"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#clients-claim-method" id="ref-for-clients-claim-method-1">claim</a>();
};
</pre>
<pre class="idl highlight def" id="serviceworker-client-query-options-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Clients" data-dfn-type="dictionary" data-export="" id="dictdef-clients-clientqueryoptions">ClientQueryOptions</dfn> {
  <span class="kt">boolean</span> <dfn class="nv dfn-paneled idl-code" data-default="false" data-dfn-for="ClientQueryOptions" data-dfn-type="dict-member" data-export="" data-type="boolean " id="dom-clientqueryoptions-includeuncontrolled">includeUncontrolled</dfn> = <span class="kt">false</span>;
  <a class="n" data-link-type="idl-name" href="#enumdef-clients-clienttype" id="ref-for-enumdef-clients-clienttype-1">ClientType</a> <dfn class="nv dfn-paneled idl-code" data-default="&quot;window&quot;" data-dfn-for="ClientQueryOptions" data-dfn-type="dict-member" data-export="" data-type="ClientType " id="dom-clientqueryoptions-type">type</dfn> = "window";
};
</pre>
<pre class="idl highlight def" id="client-type-enum"><span class="kt">enum</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Clients" data-dfn-type="enum" data-export="" id="enumdef-clients-clienttype">ClientType</dfn> {
  <dfn class="s idl-code" data-dfn-for="ClientType" data-dfn-type="enum-value" data-export="" data-lt="&quot;window&quot;|window" id="dom-clienttype-window">"window"<a class="self-link" href="#dom-clienttype-window"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="ClientType" data-dfn-type="enum-value" data-export="" data-lt="&quot;worker&quot;|worker" id="dom-clienttype-worker">"worker"<a class="self-link" href="#dom-clienttype-worker"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="ClientType" data-dfn-type="enum-value" data-export="" data-lt="&quot;sharedworker&quot;|sharedworker" id="dom-clienttype-sharedworker">"sharedworker"<a class="self-link" href="#dom-clienttype-sharedworker"></a></dfn>,
  <dfn class="s idl-code" data-dfn-for="ClientType" data-dfn-type="enum-value" data-export="" data-lt="&quot;all&quot;|all" id="dom-clienttype-all">"all"<a class="self-link" href="#dom-clienttype-all"></a></dfn>
};
</pre>
     <p>The user agent <em class="rfc2119" title="MUST">must</em> create a <code><dfn class="dfn-paneled idl-code" data-dfn-for="Clients" data-dfn-type="interface" data-export="" id="clients-interface">Clients</dfn></code> object when a <code><a href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-9">ServiceWorkerGlobalScope</a></code> object is created and associate it with that object.</p>
     <section class="algorithm" data-algorithm="clients-get">
      <h4 class="heading settled" data-level="4.3.1" id="clients-get"><span class="secno">4.3.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#clients-get-method" id="ref-for-clients-get-method-2">get(id)</a></code></span><a class="self-link" href="#clients-get"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Clients" data-dfn-type="method" data-export="" id="clients-get-method"><code>get(<var>id</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>
          For each <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-26">service worker client</a> <var>client</var> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same</a> as the associated <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-7">service worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>: 
          <ol>
           <li>
            If <var>client</var>’s <a href="#dfn-service-worker-client-id" id="ref-for-dfn-service-worker-client-id-2">id</a> is <var>id</var>, then: 
            <ol>
             <li>If <var>client</var> is not a <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure context</a>, reject <var>promise</var> with a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception and abort these steps.
             <li>
              If <var>client</var> is a <a href="#dfn-window-client" id="ref-for-dfn-window-client-4">window client</a>, then: 
              <ol>
               <li>Let <var>browsingContext</var> be <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
               <li>Let <var>visibilityState</var> be null.
               <li>Let <var>focusState</var> be null.
               <li>
                <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps: 
                <ol>
                 <li>Set <var>visibilityState</var> to <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
                 <li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
                </ol>
               <li>Wait for <var>task</var> to have executed.
               <li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>client</var>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
               <li>Resolve <var>promise</var> with <var>windowClient</var> and abort these steps.
              </ol>
             <li>
              Else: 
              <ol>
               <li>Let <var>clientObject</var> be the result of running <a href="#create-client-algorithm">Create Client</a> algorithm with <var>client</var> as the argument.
               <li>Resolve <var>promise</var> with <var>clientObject</var> and abort these steps.
              </ol>
            </ol>
          </ol>
         <li>Resolve <var>promise</var> with undefined.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="clients-getall">
      <h4 class="heading settled" data-level="4.3.2" id="clients-getall"><span class="secno">4.3.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#clients-matchall-method" id="ref-for-clients-matchall-method-2">matchAll(options)</a></code></span><a class="self-link" href="#clients-getall"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Clients" data-dfn-type="method" data-export="" data-lt="matchAll(options)|matchAll()" id="clients-matchall-method"><code>matchAll(<var>options</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>targetClients</var> be an empty array.
         <li>
          For each <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-27">service worker client</a> <var>client</var> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same</a> as the associated <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-8">service worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>: 
          <ol>
           <li>If <var>client</var> is not a <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure context</a>, continue to the next iteration of the loop.
           <li>
            If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-clientqueryoptions-includeuncontrolled" id="ref-for-dom-clientqueryoptions-includeuncontrolled-1">includeUncontrolled</a></code> is false, then: 
            <ol>
             <li>If <var>client</var>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-5">active worker</a> is the associated <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-9">service worker</a>, add <var>client</var> to <var>targetClients</var>.
            </ol>
           <li>
            Else: 
            <ol>
             <li>Add <var>client</var> to <var>targetClients</var>.
            </ol>
          </ol>
         <li>Let <var>matchedClients</var> be an empty array.
         <li>
          For each <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-28">service worker client</a> <var>client</var> in <var>targetClients</var>, in the most recently <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps">focused</a> order for <a href="#dfn-window-client" id="ref-for-dfn-window-client-5">window clients</a>: 
          <ol>
           <li>
            If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-clientqueryoptions-type" id="ref-for-dom-clientqueryoptions-type-1">type</a></code> is "<code>window</code>", and <var>client</var> is a <a href="#dfn-window-client" id="ref-for-dfn-window-client-6">window client</a>, then: 
            <ol>
             <li>Let <var>browsingContext</var> be <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
             <li>Let <var>isClientEnumerable</var> be false.
             <li>Let <var>visibilityState</var> be the empty string.
             <li>Let <var>focusState</var> be false.
             <li>
              <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substep on <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#user-interaction-task-source">user interaction task source</a>: 
              <ol>
               <li>
                If <var>browsingContext</var> has not been <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#a-browsing-context-is-discarded">discarded</a> and <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document">responsible document</a> is <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>, then: 
                <ol>
                 <li>Set <var>visibilityState</var> to <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
                 <li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
                 <li>Set <var>isClientEnumerable</var> to true.
                </ol>
              </ol>
             <li>
              Wait for <var>task</var> to have executed. 
              <p class="note" role="note">Wait is a blocking wait, but implementers may run the iterations in parallel as long as the state is not broken.</p>
             <li>
              If <var>isClientEnumerable</var> is true, then: 
              <ol>
               <li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>client</var>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
               <li>Add <var>windowClient</var> to <var>matchedClients</var>.
              </ol>
            </ol>
           <li>
            Else if <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-clientqueryoptions-type" id="ref-for-dom-clientqueryoptions-type-2">type</a></code> is "<code>worker</code>" and <var>client</var> is a <a href="#dfn-dedicatedworker-client" id="ref-for-dfn-dedicatedworker-client-2">dedicated worker client</a>, or <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-clientqueryoptions-type" id="ref-for-dom-clientqueryoptions-type-3">type</a></code> is "<code>sharedworker</code>" and <var>client</var> is a <a href="#dfn-sharedworker-client" id="ref-for-dfn-sharedworker-client-2">shared worker client</a>, then: 
            <ol>
             <li>Let <var>clientObject</var> be the result of running <a href="#create-client-algorithm">Create Client</a> algorithm with <var>client</var> as the argument.
             <li>Add <var>clientObject</var> to <var>matchedClients</var>.
            </ol>
           <li>
            Else if <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-clientqueryoptions-type" id="ref-for-dom-clientqueryoptions-type-4">type</a></code> is "<code>all</code>", then: 
            <ol>
             <li>
              If <var>client</var> is a <a href="#dfn-window-client" id="ref-for-dfn-window-client-7">window client</a>, then: 
              <ol>
               <li>Let <var>browsingContext</var> be <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
               <li>Let <var>isClientEnumerable</var> be false.
               <li>Let <var>visibilityState</var> be the empty string.
               <li>Let <var>focusState</var> be false.
               <li>
                <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substep on <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#user-interaction-task-source">user interaction task source</a>: 
                <ol>
                 <li>
                  If <var>browsingContext</var> has not been <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#a-browsing-context-is-discarded">discarded</a> and <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document">responsible document</a> is <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>, then: 
                  <ol>
                   <li>Set <var>visibilityState</var> to <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
                   <li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
                   <li>Set <var>isClientEnumerable</var> to true.
                  </ol>
                </ol>
               <li>
                Wait for <var>task</var> to have executed. 
                <p class="note" role="note">Wait is a blocking wait, but implementers may run the iterations in parallel as long as the state is not broken.</p>
               <li>
                If <var>isClientEnumerable</var> is true, then: 
                <ol>
                 <li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>client</var>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
                 <li>Add <var>windowClient</var> to <var>matchedClients</var>.
                </ol>
              </ol>
             <li>
              Else: 
              <ol>
               <li>Let <var>clientObject</var> be the result of running <a href="#create-client-algorithm">Create Client</a> algorithm with <var>client</var> as the argument.
               <li>Add <var>clientObject</var> to <var>matchedClients</var>.
              </ol>
            </ol>
          </ol>
         <li>Resolve <var>promise</var> with <var>matchedClients</var>.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="clients-openwindow">
      <h4 class="heading settled" data-level="4.3.3" id="clients-openwindow"><span class="secno">4.3.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#clients-openwindow-method" id="ref-for-clients-openwindow-method-2">openWindow(url)</a></code></span><a class="self-link" href="#clients-openwindow"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Clients" data-dfn-type="method" data-export="" id="clients-openwindow-method"><code>openWindow(<var>url</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>url</var> be the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>url</var> with the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url">API base URL</a>.
       <li>If <var>url</var> is failure, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
       <li>If <var>url</var> is <code><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#about:blank">about:blank</a></code>, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
       <li>If this algorithm is not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#triggered-by-user-activation">triggered by user activation</a>, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidaccesserror">InvalidAccessError</a></code>" exception.
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>newContext</var> be a new <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#top-level-browsing-context">top-level browsing context</a>.
         <li>Let <var>openWindowFailed</var> to false.
         <li>Let <var>visibilityState</var> be null.
         <li>Let <var>focusState</var> be null.
         <li>
          <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps on <var>newContext</var>’s <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#user-interaction-task-source">user interaction task source</a>: 
          <ol>
           <li><em>HandleNavigate</em>: <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#navigate">Navigate</a> <var>newContext</var> to <var>url</var>, with <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#exceptions-enabled">exceptions enabled</a> and <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#replacement-enabled">replacement enabled</a>.
           <li>If the algorithm steps invoked in the step labeled <em>HandleNavigate</em> <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, set <var>openWindowFailed</var> to true.
           <li>Set <var>visibilityState</var> to <var>newContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
           <li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>newContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
          </ol>
         <li>Wait for <var>task</var> to have executed (including its asynchronous steps).
         <li>If <var>openWindowFailed</var> is true, reject <var>promise</var> with a <code>TypeError</code> and abort these steps.
         <li>
          If <var>newContext</var>’s <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> is not the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same</a> as the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-10">service worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>, then: 
          <ol>
           <li>Resolve <var>promise</var> with null.
           <li>Abort these steps.
          </ol>
         <li>Let <var>client</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>newContext</var>’s <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
         <li>Resolve <var>promise</var> with <var>client</var>.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="clients-claim">
      <h4 class="heading settled" data-level="4.3.4" id="clients-claim"><span class="secno">4.3.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#clients-claim-method" id="ref-for-clients-claim-method-2">claim()</a></code></span><a class="self-link" href="#clients-claim"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Clients" data-dfn-type="method" data-export="" id="clients-claim-method"><code>claim()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>If the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-11">service worker</a> is not an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-17">active worker</a>, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception.
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>
          For each <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-29">service worker client</a> <var>client</var> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same</a> as the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-12">service worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>: 
          <ol>
           <li>If <var>client</var> is not a <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure context</a>, continue to the next iteration of the loop.
           <li>Let <var>registration</var> be the result of running <a href="#scope-match-algorithm">Match Service Worker Registration</a> algorithm passing <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a> as the argument.
           <li>If <var>registration</var> is not the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-13">service worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-8">containing service worker registration</a>, continue to the next iteration of the loop.
           <li>
            If <var>client</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-18">active worker</a> is not the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-14">service worker</a>, then: 
            <ol>
             <li>Invoke <a href="#on-client-unload-algorithm">Handle Service Worker Client Unload</a> with <var>client</var> as the argument.
             <li>Set <var>client</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-19">active worker</a> to <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-15">service worker</a>.
             <li>Invoke <a href="#notify-controller-change-algorithm">Notify Controller Change</a> algorithm with <var>client</var> as the argument.
            </ol>
          </ol>
         <li>Resolve <var>promise</var> with undefined.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="4.4" id="extendable-event"><span class="secno">4.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-1">ExtendableEvent</a></code></span><a class="self-link" href="#extendable-event"></a></h3>
<pre class="idl highlight def">[<dfn class="nv idl-code" data-dfn-for="ExtendableEvent" data-dfn-type="constructor" data-export="" data-lt="ExtendableEvent(type, eventInitDict)|ExtendableEvent(type)" id="dom-extendableevent-extendableevent">Constructor<a class="self-link" href="#dom-extendableevent-extendableevent"></a></dfn>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="ExtendableEvent/ExtendableEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-extendableevent-extendableevent-type-eventinitdict-type">type<a class="self-link" href="#dom-extendableevent-extendableevent-type-eventinitdict-type"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-extendableeventinit" id="ref-for-dictdef-extendableeventinit-1">ExtendableEventInit</a> <dfn class="nv idl-code" data-dfn-for="ExtendableEvent/ExtendableEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-extendableevent-extendableevent-type-eventinitdict-eventinitdict">eventInitDict<a class="self-link" href="#dom-extendableevent-extendableevent-type-eventinitdict-eventinitdict"></a></dfn>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#extendable-event-interface" id="ref-for-extendable-event-interface-2">ExtendableEvent</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#event">Event</a> {
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#extendable-event-waituntil-method" id="ref-for-extendable-event-waituntil-method-1">waitUntil</a>(<span class="kt">Promise</span>&lt;<span class="kt">any</span>> <dfn class="nv idl-code" data-dfn-for="ExtendableEvent/waitUntil(f)" data-dfn-type="argument" data-export="" id="dom-extendableevent-waituntil-f-f">f<a class="self-link" href="#dom-extendableevent-waituntil-f-f"></a></dfn>);
};
</pre>
<pre class="idl highlight def" id="extendable-event-init-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-type="dictionary" data-export="" id="dictdef-extendableeventinit">ExtendableEventInit</dfn> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
  // Defined for the forward compatibility across the derived events
};
</pre>
     <p>An <code><dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export="" id="extendable-event-interface" title="ExtendableEvent">ExtendableEvent</dfn></code> object has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-extend-lifetime-promises">extend lifetime promises</dfn> (an array of <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promises</a>). It is initially an empty array.</p>
     <p>An <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-3">ExtendableEvent</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="extensions-allowed-flag">extensions allowed flag</dfn>. It is initially set.</p>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-62">Service workers</a> have two <a href="#dfn-lifecycle-events" id="ref-for-dfn-lifecycle-events-1">lifecycle events</a>, <code><a href="#service-worker-global-scope-install-event" id="ref-for-service-worker-global-scope-install-event-3">install</a></code> and <code><a href="#service-worker-global-scope-activate-event" id="ref-for-service-worker-global-scope-activate-event-3">activate</a></code>. <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-63">Service workers</a> use the <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-4">ExtendableEvent</a></code> interface for <code><a href="#service-worker-global-scope-activate-event" id="ref-for-service-worker-global-scope-activate-event-4">activate</a></code> event and <code><a href="#service-worker-global-scope-install-event" id="ref-for-service-worker-global-scope-install-event-4">install</a></code> event.</p>
     <p><a href="#extensibility">Service worker extensions</a> that <a href="#extension-to-service-worker-global-scope">define event handlers</a> <em class="rfc2119" title="MAY">may</em> also use or extend the <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-5">ExtendableEvent</a></code> interface.</p>
     <p>When <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">dispatching</a> an event <var>e</var> that uses the <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-6">ExtendableEvent</a></code> interface, the user agent <em class="rfc2119" title="MUST">must</em> run these steps:</p>
     <ol>
      <li>If <var>e</var>’s <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-1">extend lifetime promises</a> is empty, unset <var>e</var>’s <a data-link-type="dfn" href="#extensions-allowed-flag" id="ref-for-extensions-allowed-flag-1">extensions allowed flag</a> and abort these steps.
      <li>Let <var>extendLifetimePromises</var> be an empty array.
      <li>
       Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
       <ol>
        <li><em>SetupPromiseArray</em>: Set <var>extendLifetimePromises</var> to a copy of <var>e</var>’s <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-2">extend lifetime promises</a>.
        <li>Wait until all the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promises</a> in <var>extendLifetimePromises</var> settle.
        <li>If the length of <var>extendLifetimePromises</var> does not equal the length of <var>e</var>’s <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-3">extend lifetime promises</a>, jump to the step labeled <em>SetupPromiseArray</em>.
        <li>Unset <var>e</var>’s <a data-link-type="dfn" href="#extensions-allowed-flag" id="ref-for-extensions-allowed-flag-2">extensions allowed flag</a>.
       </ol>
     </ol>
     <p>The user agent <em class="rfc2119" title="SHOULD NOT">should not</em> <a href="#terminate-service-worker-algorithm">terminate</a> the <a data-link-type="dfn" href="#dfn-service-worker" id="ref-for-dfn-service-worker-64">service worker</a> associated with <var>e</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> until <var>e</var>’s <a data-link-type="dfn" href="#extensions-allowed-flag" id="ref-for-extensions-allowed-flag-3">extensions allowed flag</a> is unset. However, the user agent <em class="rfc2119" title="MAY">may</em> impose a time limit to this lifetime extension.</p>
     <section class="algorithm" data-algorithm="wait-until-method">
      <h4 class="heading settled" data-level="4.4.1" id="wait-until-method"><span class="secno">4.4.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendable-event-waituntil-method" id="ref-for-extendable-event-waituntil-method-2">event.waitUntil(f)</a></code></span><a class="self-link" href="#wait-until-method"></a></h4>
      <p><code class="idl"><a data-link-type="idl" href="#extendable-event-waituntil-method" id="ref-for-extendable-event-waituntil-method-3">waitUntil(f)</a></code> method extends the lifetime of the event.</p>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="ExtendableEvent" data-dfn-type="method" data-export="" id="extendable-event-waituntil-method"><code>waitUntil(<var>f</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>
        If the <a data-link-type="dfn" href="#extensions-allowed-flag" id="ref-for-extensions-allowed-flag-4">extensions allowed flag</a> is unset, then: 
        <ol>
         <li><a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">Throw</a> an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception.
         <li>Abort these steps.
        </ol>
       <li>Add <var>f</var> to the <a href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-10">extend lifetime promises</a>.
      </ol>
     </section>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-65">Service workers</a> and <a href="#extensibility">extensions</a> that <a href="#extension-to-service-worker-global-scope">define event handlers</a> <em class="rfc2119" title="MAY">may</em> define their own behaviors, allowing the <a href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-4">extend lifetime promises</a> to suggest operation length, and the rejected state of any of the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> in <a href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-5">extend lifetime promises</a> to suggest operation failure.</p>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-66">Service workers</a> define the following behaviors for <code><a href="#service-worker-global-scope-install-event" id="ref-for-service-worker-global-scope-install-event-5">install</a></code> event and <code><a href="#service-worker-global-scope-activate-event" id="ref-for-service-worker-global-scope-activate-event-5">activate</a></code> event, respectively:</p>
     <ul>
      <li>Adding a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> <var>f</var> to the event’s <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-6">extend lifetime promises</a> delays treating the <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-5">installing worker</a> as <em><a href="#dfn-state" id="ref-for-dfn-state-7">installed</a></em> (i.e. a <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-4">waiting worker</a>) until all the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promises</a> in the <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-7">extend lifetime promises</a> resolve successfully. (See step 11.3.1 of <a href="#installation-algorithm">Install</a> algorithm.) If <var>f</var> rejects, the installation fails. This is primarily used to ensure that a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-67">service worker</a> is not considered <em><a href="#dfn-state" id="ref-for-dfn-state-8">installed</a></em> (i.e. a <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-5">waiting worker</a>) until all of the core caches it depends on are populated.
      <li>Adding a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> to the event’s <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-8">extend lifetime promises</a> delays treating the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-20">active worker</a> as <em><a href="#dfn-state" id="ref-for-dfn-state-9">activated</a></em> until all the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promises</a> in the <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-9">extend lifetime promises</a> settle. (See step 12.3 of <a href="#activation-algorithm">Activate</a> algorithm.) This is primarily used to ensure that any <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-2">functional events</a> are not dispatched to the <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-10">ServiceWorkerGlobalScope</a></code> object that represents the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-68">service worker</a> until it upgrades database schemas and deletes the outdated cache entries.
     </ul>
    </section>
    <section>
     <h3 class="heading settled" data-level="4.5" id="fetch-event-section"><span class="secno">4.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#fetch-event-interface" id="ref-for-fetch-event-interface-1">FetchEvent</a></code></span><a class="self-link" href="#fetch-event-section"></a></h3>
<pre class="idl highlight def">[<dfn class="nv idl-code" data-dfn-for="FetchEvent" data-dfn-type="constructor" data-export="" data-lt="FetchEvent(type, eventInitDict)" id="dom-fetchevent-fetchevent">Constructor<a class="self-link" href="#dom-fetchevent-fetchevent"></a></dfn>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="FetchEvent/FetchEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-fetchevent-fetchevent-type-eventinitdict-type">type<a class="self-link" href="#dom-fetchevent-fetchevent-type-eventinitdict-type"></a></dfn>, <a class="n" data-link-type="idl-name" href="#dictdef-fetchevent-fetcheventinit" id="ref-for-dictdef-fetchevent-fetcheventinit-1">FetchEventInit</a> <dfn class="nv idl-code" data-dfn-for="FetchEvent/FetchEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-fetchevent-fetchevent-type-eventinitdict-eventinitdict">eventInitDict<a class="self-link" href="#dom-fetchevent-fetchevent-type-eventinitdict-eventinitdict"></a></dfn>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#fetch-event-interface" id="ref-for-fetch-event-interface-2">FetchEvent</a> : <a class="n" data-link-type="idl-name" href="#extendable-event-interface" id="ref-for-extendable-event-interface-7">ExtendableEvent</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Request" href="#fetch-event-request-attribute" id="ref-for-fetch-event-request-attribute-1">request</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString?" href="#fetch-event-clientid-attribute" id="ref-for-fetch-event-clientid-attribute-1">clientId</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="#fetch-event-isreload-attribute" id="ref-for-fetch-event-isreload-attribute-1">isReload</a>;

  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#fetch-event-respondwith-method" id="ref-for-fetch-event-respondwith-method-1">respondWith</a>(<span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a>> <dfn class="nv idl-code" data-dfn-for="FetchEvent/respondWith(r)" data-dfn-type="argument" data-export="" id="dom-fetchevent-respondwith-r-r">r<a class="self-link" href="#dom-fetchevent-respondwith-r-r"></a></dfn>);
};
</pre>
<pre class="idl highlight def" id="fetch-event-init-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="FetchEvent" data-dfn-type="dictionary" data-export="" id="dictdef-fetchevent-fetcheventinit">FetchEventInit</dfn> : <a class="n" data-link-type="idl-name" href="#dictdef-extendableeventinit" id="ref-for-dictdef-extendableeventinit-2">ExtendableEventInit</a> {
  <span class="kt">required</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a> <dfn class="nv idl-code" data-dfn-for="FetchEventInit" data-dfn-type="dict-member" data-export="" data-type="Request " id="dom-fetcheventinit-request">request<a class="self-link" href="#dom-fetcheventinit-request"></a></dfn>;
  <span class="kt">DOMString</span>? <dfn class="nv idl-code" data-default="null" data-dfn-for="FetchEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString? " id="dom-fetcheventinit-clientid">clientId<a class="self-link" href="#dom-fetcheventinit-clientid"></a></dfn> = <span class="kt">null</span>;
  <span class="kt">boolean</span> <dfn class="nv idl-code" data-default="false" data-dfn-for="FetchEventInit" data-dfn-type="dict-member" data-export="" data-type="boolean " id="dom-fetcheventinit-isreload">isReload<a class="self-link" href="#dom-fetcheventinit-isreload"></a></dfn> = <span class="kt">false</span>;
};
</pre>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-69">Service workers</a> have an essential <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-3">functional event</a> <code><a href="#service-worker-global-scope-fetch-event" id="ref-for-service-worker-global-scope-fetch-event-4">fetch</a></code>. For <code><a href="#service-worker-global-scope-fetch-event" id="ref-for-service-worker-global-scope-fetch-event-5">fetch</a></code> event, <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-70">service workers</a> use the <code><dfn class="dfn-paneled idl-code" data-dfn-for="FetchEvent" data-dfn-type="interface" data-export="" id="fetch-event-interface">FetchEvent</dfn></code> interface which extends the <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-8">ExtendableEvent</a></code> interface.</p>
     <p>Each event using <code class="idl"><a data-link-type="idl" href="#fetch-event-interface" id="ref-for-fetch-event-interface-3">FetchEvent</a></code> interface has an associated <dfn class="dfn-paneled" data-dfn-for="FetchEvent" data-dfn-type="dfn" data-noexport="" id="fetchevent-potential-response">potential response</dfn> (a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response">response</a>), initially set to null, and the following associated flags that are initially unset: </p>
     <ul>
      <li><dfn class="dfn-paneled" data-dfn-for="FetchEvent" data-dfn-type="dfn" data-noexport="" id="wait-to-respond-flag">wait to respond flag</dfn>
      <li><dfn class="dfn-paneled" data-dfn-for="FetchEvent" data-dfn-type="dfn" data-noexport="" id="respond-with-entered-flag">respond-with entered flag</dfn>
      <li><dfn class="dfn-paneled" data-dfn-for="FetchEvent" data-dfn-type="dfn" data-noexport="" id="respond-with-error-flag">respond-with error flag</dfn>
     </ul>
     <p></p>
     <section>
      <h4 class="heading settled" data-level="4.5.1" id="fetch-event-request"><span class="secno">4.5.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#fetch-event-request-attribute" id="ref-for-fetch-event-request-attribute-2">event.request</a></code></span><a class="self-link" href="#fetch-event-request"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="FetchEvent" data-dfn-type="attribute" data-export="" id="fetch-event-request-attribute"><code>request</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.5.2" id="fetch-event-clientid"><span class="secno">4.5.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#fetch-event-clientid-attribute" id="ref-for-fetch-event-clientid-attribute-2">event.clientId</a></code></span><a class="self-link" href="#fetch-event-clientid"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="FetchEvent" data-dfn-type="attribute" data-export="" id="fetch-event-clientid-attribute"><code>clientId</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When an <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">event</a> is created the attribute <em class="rfc2119" title="MUST">must</em> be initialized to null.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.5.3" id="fetch-event-isreload"><span class="secno">4.5.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#fetch-event-isreload-attribute" id="ref-for-fetch-event-isreload-attribute-2">event.isReload</a></code></span><a class="self-link" href="#fetch-event-isreload"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="FetchEvent" data-dfn-type="attribute" data-export="" id="fetch-event-isreload-attribute"><code>isReload</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When an <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event">event</a> is created the attribute <em class="rfc2119" title="MUST">must</em> be initialized to false.</p>
      <p class="note" role="note">Pressing the refresh button should be considered a reload while clicking a link and pressing the back button should not. The behavior of the <var>Ctrl+l enter</var> is left to the implementations of the user agents.</p>
     </section>
     <section class="algorithm" data-algorithm="fetch-event-respondwith">
      <h4 class="heading settled" data-level="4.5.4" id="fetch-event-respondwith"><span class="secno">4.5.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#fetch-event-respondwith-method" id="ref-for-fetch-event-respondwith-method-2">event.respondWith(r)</a></code></span><a class="self-link" href="#fetch-event-respondwith"></a></h4>
      <p class="note" role="note">Developers can set the argument <var>r</var> with either a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> that resolves with a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object or a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object (which is automatically cast to a promise). Otherwise, a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a> is returned to <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">Fetch</a>. Renderer-side security checks about tainting for cross-origin content are tied to the types of <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-filtered-response">filtered responses</a> defined in <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">Fetch</a>.</p>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="FetchEvent" data-dfn-type="method" data-export="" id="fetch-event-respondwith-method"><code>respondWith(<var>r</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol data-link-for-hint="FetchEvent">
       <li>
        If the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#dispatch-flag">dispatch flag</a> is unset, then: 
        <ol>
         <li><a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">Throw</a> an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception.
         <li>Abort these steps.
        </ol>
       <li>
        If the <a href="#respond-with-entered-flag" id="ref-for-respond-with-entered-flag-1">respond-with entered flag</a> is set, then: 
        <ol>
         <li><a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">Throw</a> an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception.
         <li>Abort these steps.
        </ol>
       <li>
        Add <var>r</var> to the <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-11">extend lifetime promises</a>. 
        <p class="note" role="note"><code class="idl"><a data-link-type="idl" href="#fetch-event-respondwith-method" id="ref-for-fetch-event-respondwith-method-3">event.respondWith(r)</a></code> extends the lifetime of the event by default as if <code class="idl"><a data-link-type="idl" href="#extendable-event-waituntil-method" id="ref-for-extendable-event-waituntil-method-4">event.waitUntil(r)</a></code> is called.</p>
       <li>Set the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#stop-propagation-flag">stop propagation flag</a> and <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#stop-immediate-propagation-flag">stop immediate propagation flag</a>.
       <li>Set the <a href="#respond-with-entered-flag" id="ref-for-respond-with-entered-flag-2">respond-with entered flag</a>.
       <li>Set the <a href="#wait-to-respond-flag" id="ref-for-wait-to-respond-flag-1">wait to respond flag</a>.
       <li>Let <var>targetRealm</var> be the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-realm">relevant Realm</a> of the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>. 
       <li>
        Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Wait until <var>r</var> settles.
         <li>
          If <var>r</var> rejected, then: 
          <ol>
           <li>Set the <a href="#respond-with-error-flag" id="ref-for-respond-with-error-flag-1">respond-with error flag</a>.
          </ol>
         <li>
          If <var>r</var> resolved with <var>response</var>, then: 
          <ol>
           <li>
            If <var>response</var> is a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object, then: 
            <ol>
             <li>
              If <var>response</var> is <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-disturbed">disturbed</a> or <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-locked">locked</a>, then: 
              <ol>
               <li>Set the <a href="#respond-with-error-flag" id="ref-for-respond-with-error-flag-2">respond-with error flag</a>.
              </ol>
             <li>
              Else: 
              <ol>
               <li>Let <var>bytes</var> be an empty byte sequence. 
               <li>Let <var>end-of-body</var> be false. 
               <li>Let <var>done</var> be false. 
               <li>Let <var>potentialResponse</var> be a copy of <var>response</var>’s associated <a href="https://fetch.spec.whatwg.org/#concept-response-response">response</a>, except for its <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a>.
               <li>
                If <var>response</var>’s body is non-null, run these substeps: 
                <ol>
                 <li>Let <var>reader</var> be the result of <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-get-reader">getting a reader</a> from <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-stream">stream</a>.
                 <li>Let <var>strategy</var> be an object created in <var>targetRealm</var>. The user agent may choose any object.
                 <li>
                  Let <var>pull</var> be an action that runs these subsubsteps: 
                  <ol>
                   <li>Let <var>promise</var> be the result of <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-read-chunk-from-readablestream">reading</a> a chunk from <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-stream">stream</a> with <var>reader</var>.
                   <li>When <var>promise</var> is fulfilled with an object whose <code>done</code> property is false and whose <code>value</code> property is a <code>Uint8Array</code> object, append the bytes represented by the <code>value</code> property to <var>bytes</var> and perform ! <a href="https://tc39.github.io/ecma262/#sec-detacharraybuffer">DetachArrayBuffer</a> with the <code>ArrayBuffer</code> object wrapped by the <code>value</code> property.
                   <li>When <var>promise</var> is fulfilled with an object whose <code>done</code> property is true, set <var>end-of-body</var> to true.
                   <li>When <var>promise</var> is fulfilled with a value that matches with neither of the above patterns, or <var>promise</var> is rejected, <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-error-readablestream">error</a> <var>newStream</var> with a <code>TypeError</code>.
                  </ol>
                 <li>Let <var>cancel</var> be an action that <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-cancel-readablestream">cancels</a> <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-stream">stream</a> with <var>reader</var>.
                 <li>Let <var>newStream</var> be the result of <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-construct-readablestream">constructing</a> a ReadableStream object with <var>strategy</var>, <var>pull</var> and <var>cancel</var> in <var>targetRealm</var>.
                 <li>Set <var>potentialResponse</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a> to a new <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a> whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-stream">stream</a> is <var>newStream</var>.
                 <li>Run these subsubsteps repeatedly <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a> while <var>done</var> is false:
                 <ol>
                  <li>If <var>newStream</var> is <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-readablestream-errored">errored</a>, then set <var>done</var> to true.
                  <li>Otherwise, if <var>bytes</var> is empty and <var>end-of-body</var> is true, then <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-close-readablestream">close</a> <var>newStream</var> and set <var>done</var> to true.
                  <li>
                   Otherwise, if <var>bytes</var> is not empty, run these subsubsubsteps: 
                   <ol>
                    <li>Let <var>chunk</var> be a subsequence of <var>bytes</var> starting from the beginning of <var>bytes</var>.
                    <li>Remove <var>chunk</var> from <var>bytes</var>. 
                    <li>Let <var>buffer</var> be an <code>ArrayBuffer</code> object created in <var>targetRealm</var> and containing <var>chunk</var>. 
                    <li><a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-enqueue-readablestream">Enqueue</a> a <code>Uint8Array</code> object created in <var>targetRealm</var> and wrapping <var>buffer</var> to <var>newStream</var>. 
                   </ol>
                 </ol>
                </ol>
                <p class="note" role="note">These substeps are meant to produce the observable equivalent of "piping" <var>response</var>’s <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-stream">stream</a> into <var>potentialResponse</var>.</p>
               <li>Set the <a data-link-type="dfn" href="#fetchevent-potential-response" id="ref-for-fetchevent-potential-response-1">potential response</a> to <var>potentialResponse</var>.
              </ol>
            </ol>
           <li>
            Else: 
            <ol>
             <li>Set the <a href="#respond-with-error-flag" id="ref-for-respond-with-error-flag-3">respond-with error flag</a>.
            </ol>
            <p class="note" role="note">If the <a href="#respond-with-error-flag" id="ref-for-respond-with-error-flag-4">respond-with error flag</a> is set, a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a> is returned to <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">Fetch</a> through <a href="#on-fetch-request-algorithm">Handle Fetch</a> algorithm. (See the step 21.1.) Otherwise, the value <var>response</var> is returned to <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">Fetch</a> through <a href="#on-fetch-request-algorithm">Handle Fetch</a> algorithm. (See the step 22.1.)</p>
          </ol>
         <li>Unset the <a href="#wait-to-respond-flag" id="ref-for-wait-to-respond-flag-2">wait to respond flag</a>.
        </ol>
      </ol>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="4.6" id="extendablemessage-event-section"><span class="secno">4.6. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendablemessage-event-interface" id="ref-for-extendablemessage-event-interface-2">ExtendableMessageEvent</a></code></span><a class="self-link" href="#extendablemessage-event-section"></a></h3>
<pre class="idl highlight def">[<dfn class="nv idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="constructor" data-export="" data-lt="ExtendableMessageEvent(type, eventInitDict)|ExtendableMessageEvent(type)" id="dom-extendablemessageevent-extendablemessageevent">Constructor<a class="self-link" href="#dom-extendablemessageevent-extendablemessageevent"></a></dfn>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="ExtendableMessageEvent/ExtendableMessageEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-extendablemessageevent-extendablemessageevent-type-eventinitdict-type">type<a class="self-link" href="#dom-extendablemessageevent-extendablemessageevent-type-eventinitdict-type"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-extendablemessageevent-extendablemessageeventinit" id="ref-for-dictdef-extendablemessageevent-extendablemessageeventinit-1">ExtendableMessageEventInit</a> <dfn class="nv idl-code" data-dfn-for="ExtendableMessageEvent/ExtendableMessageEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-extendablemessageevent-extendablemessageevent-type-eventinitdict-eventinitdict">eventInitDict<a class="self-link" href="#dom-extendablemessageevent-extendablemessageevent-type-eventinitdict-eventinitdict"></a></dfn>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#extendablemessage-event-interface" id="ref-for-extendablemessage-event-interface-3">ExtendableMessageEvent</a> : <a class="n" data-link-type="idl-name" href="#extendable-event-interface" id="ref-for-extendable-event-interface-9">ExtendableEvent</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">any</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="any" href="#extendablemessage-event-data-attribute" id="ref-for-extendablemessage-event-data-attribute-2">data</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#extendablemessage-event-origin-attribute" id="ref-for-extendablemessage-event-origin-attribute-2">origin</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#extendablemessage-event-lasteventid-attribute" id="ref-for-extendablemessage-event-lasteventid-attribute-1">lastEventId</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> (<a class="n" data-link-type="idl-name" href="#client-interface" id="ref-for-client-interface-6">Client</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-27">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="(Client or ServiceWorker or MessagePort)?" href="#extendablemessage-event-source-attribute" id="ref-for-extendablemessage-event-source-attribute-3">source</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">FrozenArray</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="FrozenArray<MessagePort>?" href="#extendablemessage-event-ports-attribute" id="ref-for-extendablemessage-event-ports-attribute-2">ports</a>;
};
</pre>
<pre class="idl highlight def" id="extendablemessage-event-init-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="dictionary" data-export="" id="dictdef-extendablemessageevent-extendablemessageeventinit">ExtendableMessageEventInit</dfn> : <a class="n" data-link-type="idl-name" href="#dictdef-extendableeventinit" id="ref-for-dictdef-extendableeventinit-3">ExtendableEventInit</a> {
  <span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="ExtendableMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="any " id="dom-extendablemessageeventinit-data">data<a class="self-link" href="#dom-extendablemessageeventinit-data"></a></dfn>;
  <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="ExtendableMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-extendablemessageeventinit-origin">origin<a class="self-link" href="#dom-extendablemessageeventinit-origin"></a></dfn>;
  <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="ExtendableMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-extendablemessageeventinit-lasteventid">lastEventId<a class="self-link" href="#dom-extendablemessageeventinit-lasteventid"></a></dfn>;
  (<a class="n" data-link-type="idl-name" href="#client-interface" id="ref-for-client-interface-7">Client</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface" id="ref-for-service-worker-interface-28">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <dfn class="nv idl-code" data-dfn-for="ExtendableMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="(Client or ServiceWorker or MessagePort)? " id="dom-extendablemessageeventinit-source">source<a class="self-link" href="#dom-extendablemessageeventinit-source"></a></dfn>;
  <span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <dfn class="nv idl-code" data-dfn-for="ExtendableMessageEventInit" data-dfn-type="dict-member" data-export="" data-type="sequence<MessagePort>? " id="dom-extendablemessageeventinit-ports">ports<a class="self-link" href="#dom-extendablemessageeventinit-ports"></a></dfn>;
};
</pre>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-71">Service workers</a> define the <a href="#extendable-event-waituntil-method" id="ref-for-extendable-event-waituntil-method-5">extendable</a> <a href="#service-worker-global-scope-message-event" id="ref-for-service-worker-global-scope-message-event-3">message</a> event that extends the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/indices.html#event-message">message</a></code> event defined in <a data-link-type="biblio" href="#biblio-html">[HTML]</a> to allow extending the lifetime of the event. For the <a href="#service-worker-global-scope-message-event" id="ref-for-service-worker-global-scope-message-event-4">message</a> event, <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-72">service workers</a> use the <code><dfn class="dfn-paneled idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="interface" data-export="" id="extendablemessage-event-interface">ExtendableMessageEvent</dfn></code> interface which extends the <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-10">ExtendableEvent</a></code> interface.</p>
     <section>
      <h4 class="heading settled" data-level="4.6.1" id="extendablemessage-event-data"><span class="secno">4.6.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendablemessage-event-data-attribute" id="ref-for-extendablemessage-event-data-attribute-3">event.data</a></code></span><a class="self-link" href="#extendablemessage-event-data"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="attribute" data-export="" id="extendablemessage-event-data-attribute">data</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the message being sent.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.6.2" id="extendablemessage-event-origin"><span class="secno">4.6.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendablemessage-event-origin-attribute" id="ref-for-extendablemessage-event-origin-attribute-3">event.origin</a></code></span><a class="self-link" href="#extendablemessage-event-origin"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="attribute" data-export="" id="extendablemessage-event-origin-attribute">origin</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to the empty string. It represents the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-30">service worker client</a> that sent the message.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.6.3" id="extendablemessage-event-lasteventid"><span class="secno">4.6.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendablemessage-event-lasteventid-attribute" id="ref-for-extendablemessage-event-lasteventid-attribute-2">event.lastEventId</a></code></span><a class="self-link" href="#extendablemessage-event-lasteventid"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="attribute" data-export="" id="extendablemessage-event-lasteventid-attribute">lastEventId</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to the empty string.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.6.4" id="extendablemessage-event-source"><span class="secno">4.6.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendablemessage-event-source-attribute" id="ref-for-extendablemessage-event-source-attribute-4">event.source</a></code></span><a class="self-link" href="#extendablemessage-event-source"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="attribute" data-export="" id="extendablemessage-event-source-attribute">source</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the <code class="idl"><a data-link-type="idl" href="#client-interface" id="ref-for-client-interface-8">Client</a></code> object from which the message is sent.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="4.6.5" id="extendablemessage-event-ports"><span class="secno">4.6.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#extendablemessage-event-ports-attribute" id="ref-for-extendablemessage-event-ports-attribute-3">event.ports</a></code></span><a class="self-link" href="#extendablemessage-event-ports"></a></h4>
      <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="ExtendableMessageEvent" data-dfn-type="attribute" data-export="" id="extendablemessage-event-ports-attribute">ports</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a></code> array being sent, if any.</p>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="4.7" id="execution-context-events"><span class="secno">4.7. </span><span class="content">Events</span><a class="self-link" href="#execution-context-events"></a></h3>
     <p>The following events are dispatched on <a href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-11">ServiceWorkerGlobalScope</a> object:</p>
     <table class="data">
      <thead>
       <tr>
        <th>Event name
        <th>Interface
        <th>Dispatched when…
      <tbody>
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="event" data-export="" id="service-worker-global-scope-install-event"><code>install</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-11">ExtendableEvent</a></code>
        <td>[<a href="#dfn-lifecycle-events" id="ref-for-dfn-lifecycle-events-2">Lifecycle event</a>] The <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-16">service worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-9">containing service worker registration</a>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-6">installing worker</a> changes. (See step 11.2 of the <a href="#installation-algorithm">Install</a> algorithm.)
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="event" data-export="" id="service-worker-global-scope-activate-event"><code>activate</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-12">ExtendableEvent</a></code>
        <td>[<a href="#dfn-lifecycle-events" id="ref-for-dfn-lifecycle-events-3">Lifecycle event</a>] The <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-17">service worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-10">containing service worker registration</a>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-21">active worker</a> changes. (See step 12.2 of the <a href="#activation-algorithm">Activate</a> algorithm.)
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="event" data-export="" id="service-worker-global-scope-fetch-event"><code>fetch</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="#fetch-event-interface" id="ref-for-fetch-event-interface-4">FetchEvent</a></code>
        <td>[<a href="#dfn-functional-events" id="ref-for-dfn-functional-events-4">Functional event</a>] The <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-http-fetch">http fetch</a> invokes <a href="#on-fetch-request-algorithm">Handle Fetch</a> with <var>request</var>. As a result of performing <a href="#on-fetch-request-algorithm">Handle Fetch</a>, the <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-18">service worker</a> returns a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response">response</a> to the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-http-fetch">http fetch</a>. The <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response">response</a>, represented by a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object, can be retrieved from a <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-1">Cache</a></code> object or directly from network using <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#dom-global-fetch">self.fetch(input, init)</a></code> method. (A custom <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object can be another option.)
       <tr>
        <td><dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="event" data-export="" id="service-worker-global-scope-message-event"><code>message</code></dfn>
        <td><code class="idl"><a data-link-type="idl" href="#extendablemessage-event-interface" id="ref-for-extendablemessage-event-interface-4">ExtendableMessageEvent</a></code>
        <td>When it receives a message.
     </table>
    </section>
   </section>
   <section>
    <h2 class="heading settled" data-level="5" id="cache-objects"><span class="secno">5. </span><span class="content">Caches</span><a class="self-link" href="#cache-objects"></a></h2>
    <p>To allow authors to fully manage their content caches for offline use, the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> and the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#workerglobalscope">WorkerGlobalScope</a></code> provide the asynchronous caching methods that open and manipulate <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-2">Cache</a></code> objects. An <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> can have multiple, named <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-3">Cache</a></code> objects, whose contents are entirely under the control of scripts. Caches are not shared across <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origins</a>, and they are completely isolated from the browser’s HTTP cache.</p>
    <section>
     <h3 class="heading settled" data-level="5.1" id="cache-constructs"><span class="secno">5.1. </span><span class="content">Constructs</span><a class="self-link" href="#cache-constructs"></a></h3>
     <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-fetching-record">fetching record</dfn> is a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} where [[key]] is a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> and [[value]] is a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code>.</p>
     <p>A <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-1">fetching record</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-incumbent-record">incumbent record</dfn> (a <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-2">fetching record</a>). It is initially set to null.</p>
     <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-request-to-response-map">request to response map</dfn> is a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">List</a> of <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-3">fetching records</a>.</p>
     <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-name-to-cache-map">name to cache map</dfn> is a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">List</a> of the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} where [[key]] is a string that represents a name of the <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-4">Cache</a></code> object and [[value]] is a <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-5">Cache</a></code> object.</p>
     <p>Each <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> has an associated <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-1">name to cache map</a>.</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="5.2" id="cache-lifetimes"><span class="secno">5.2. </span><span class="content">Understanding Cache Lifetimes</span><a class="self-link" href="#cache-lifetimes"></a></h3>
     <p>The <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-6">Cache</a></code> instances are not part of the browser’s HTTP cache. The <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-7">Cache</a></code> objects are exactly what authors have to manage themselves. The <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-8">Cache</a></code> objects do not get updated unless authors explicitly request them to be. The <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-9">Cache</a></code> objects do not expire unless authors delete the entries. The <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-10">Cache</a></code> objects do not disappear just because the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-73">service worker</a> script is updated. That is, caches are not updated automatically. Updates must be manually managed. This implies that authors should version their caches by name and make sure to use the caches only from the version of the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-74">service worker</a> that can safely operate on.</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="5.3" id="self-caches"><span class="secno">5.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#global-caches-attribute" id="ref-for-global-caches-attribute-1">self.caches</a></code></span><a class="self-link" href="#self-caches"></a></h3>
<pre class="idl highlight def"><span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#cache-storage-interface" id="ref-for-cache-storage-interface-1">CacheStorage</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="CacheStorage" href="#global-caches-attribute" id="ref-for-global-caches-attribute-2">caches</a>;
};
</pre>
     <section>
      <h4 class="heading settled" data-level="5.3.1" id="global-caches"><span class="secno">5.3.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#global-caches-attribute" id="ref-for-global-caches-attribute-3">caches</a></code></span><a class="self-link" href="#global-caches"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="WindowOrWorkerGlobalScope" data-dfn-type="attribute" data-export="" id="global-caches-attribute"><code>caches</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return this object’s associated <code class="idl"><a data-link-type="idl" href="#cache-storage-interface" id="ref-for-cache-storage-interface-2">CacheStorage</a></code> object.</p>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="5.4" id="cache"><span class="secno">5.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-11">Cache</a></code></span><a class="self-link" href="#cache"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#cache-interface" id="ref-for-cache-interface-12">Cache</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#cache-match-method" id="ref-for-cache-match-method-1">match</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <dfn class="nv idl-code" data-dfn-for="Cache/match(request, options), Cache/match(request)" data-dfn-type="argument" data-export="" id="dom-cache-match-request-options-request">request<a class="self-link" href="#dom-cache-match-request-options-request"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions" id="ref-for-dictdef-cache-cachequeryoptions-1">CacheQueryOptions</a> <dfn class="nv idl-code" data-dfn-for="Cache/match(request, options), Cache/match(request)" data-dfn-type="argument" data-export="" id="dom-cache-match-request-options-options">options<a class="self-link" href="#dom-cache-match-request-options-options"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a>>> <a class="nv idl-code" data-link-type="method" href="#cache-matchall-method" id="ref-for-cache-matchall-method-1">matchAll</a>(<span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <dfn class="nv idl-code" data-dfn-for="Cache/matchAll(request, options), Cache/matchAll(request), Cache/matchAll()" data-dfn-type="argument" data-export="" id="dom-cache-matchall-request-options-request">request<a class="self-link" href="#dom-cache-matchall-request-options-request"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions" id="ref-for-dictdef-cache-cachequeryoptions-2">CacheQueryOptions</a> <dfn class="nv idl-code" data-dfn-for="Cache/matchAll(request, options), Cache/matchAll(request), Cache/matchAll()" data-dfn-type="argument" data-export="" id="dom-cache-matchall-request-options-options">options<a class="self-link" href="#dom-cache-matchall-request-options-options"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#cache-add-method" id="ref-for-cache-add-method-1">add</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <dfn class="nv idl-code" data-dfn-for="Cache/add(request)" data-dfn-type="argument" data-export="" id="dom-cache-add-request-request">request<a class="self-link" href="#dom-cache-add-request-request"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#cache-addAll-method" id="ref-for-cache-addAll-method-1">addAll</a>(<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a>> <dfn class="nv idl-code" data-dfn-for="Cache/addAll(requests)" data-dfn-type="argument" data-export="" id="dom-cache-addall-requests-requests">requests<a class="self-link" href="#dom-cache-addall-requests-requests"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#cache-put-method" id="ref-for-cache-put-method-1">put</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <dfn class="nv idl-code" data-dfn-for="Cache/put(request, response)" data-dfn-type="argument" data-export="" id="dom-cache-put-request-response-request">request<a class="self-link" href="#dom-cache-put-request-response-request"></a></dfn>, <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a> <dfn class="nv idl-code" data-dfn-for="Cache/put(request, response)" data-dfn-type="argument" data-export="" id="dom-cache-put-request-response-response">response<a class="self-link" href="#dom-cache-put-request-response-response"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#cache-delete-method" id="ref-for-cache-delete-method-1">delete</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <dfn class="nv idl-code" data-dfn-for="Cache/delete(request, options), Cache/delete(request)" data-dfn-type="argument" data-export="" id="dom-cache-delete-request-options-request">request<a class="self-link" href="#dom-cache-delete-request-options-request"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions" id="ref-for-dictdef-cache-cachequeryoptions-3">CacheQueryOptions</a> <dfn class="nv idl-code" data-dfn-for="Cache/delete(request, options), Cache/delete(request)" data-dfn-type="argument" data-export="" id="dom-cache-delete-request-options-options">options<a class="self-link" href="#dom-cache-delete-request-options-options"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a>>> <a class="nv idl-code" data-link-type="method" href="#cache-keys-method" id="ref-for-cache-keys-method-1">keys</a>(<span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <dfn class="nv idl-code" data-dfn-for="Cache/keys(request, options), Cache/keys(request), Cache/keys()" data-dfn-type="argument" data-export="" id="dom-cache-keys-request-options-request">request<a class="self-link" href="#dom-cache-keys-request-options-request"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions" id="ref-for-dictdef-cache-cachequeryoptions-4">CacheQueryOptions</a> <dfn class="nv idl-code" data-dfn-for="Cache/keys(request, options), Cache/keys(request), Cache/keys()" data-dfn-type="argument" data-export="" id="dom-cache-keys-request-options-options">options<a class="self-link" href="#dom-cache-keys-request-options-options"></a></dfn>);
};
</pre>
<pre class="idl highlight def" id="cache-query-options-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="dictionary" data-export="" id="dictdef-cache-cachequeryoptions">CacheQueryOptions</dfn> {
  <span class="kt">boolean</span> <dfn class="nv dfn-paneled idl-code" data-default="false" data-dfn-for="CacheQueryOptions" data-dfn-type="dict-member" data-export="" data-type="boolean " id="dom-cachequeryoptions-ignoresearch">ignoreSearch</dfn> = <span class="kt">false</span>;
  <span class="kt">boolean</span> <dfn class="nv dfn-paneled idl-code" data-default="false" data-dfn-for="CacheQueryOptions" data-dfn-type="dict-member" data-export="" data-type="boolean " id="dom-cachequeryoptions-ignoremethod">ignoreMethod</dfn> = <span class="kt">false</span>;
  <span class="kt">boolean</span> <dfn class="nv dfn-paneled idl-code" data-default="false" data-dfn-for="CacheQueryOptions" data-dfn-type="dict-member" data-export="" data-type="boolean " id="dom-cachequeryoptions-ignorevary">ignoreVary</dfn> = <span class="kt">false</span>;
  <span class="kt">DOMString</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="CacheQueryOptions" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-cachequeryoptions-cachename">cacheName</dfn>;
};
</pre>
<pre class="idl highlight def" id="cache-batch-operation-dictionary"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="dictionary" data-export="" id="dictdef-cache-cachebatchoperation">CacheBatchOperation</dfn> {
  <span class="kt">DOMString</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="CacheBatchOperation" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-cachebatchoperation-type">type</dfn>;
  <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a> <dfn class="nv dfn-paneled idl-code" data-dfn-for="CacheBatchOperation" data-dfn-type="dict-member" data-export="" data-type="Request " id="dom-cachebatchoperation-request">request</dfn>;
  <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a> <dfn class="nv dfn-paneled idl-code" data-dfn-for="CacheBatchOperation" data-dfn-type="dict-member" data-export="" data-type="Response " id="dom-cachebatchoperation-response">response</dfn>;
  <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions" id="ref-for-dictdef-cache-cachequeryoptions-5">CacheQueryOptions</a> <dfn class="nv dfn-paneled idl-code" data-dfn-for="CacheBatchOperation" data-dfn-type="dict-member" data-export="" data-type="CacheQueryOptions " id="dom-cachebatchoperation-options">options</dfn>;
};
</pre>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="interface" data-export="" id="cache-interface">Cache</dfn></code> object represents a <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-1">request to response map</a>. Multiple separate objects implementing the <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-13">Cache</a></code> interface across documents and workers can all be associated with the same <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-2">request to response map</a> simultaneously.</p>
     <p><code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-14">Cache</a></code> objects are always enumerable via <code class="idl"><a data-link-type="idl" href="#global-caches-attribute" id="ref-for-global-caches-attribute-4">self.caches</a></code> in insertion order (per <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-map-objects">ECMAScript 6 Map objects</a>).</p>
     <section class="algorithm" data-algorithm="cache-match">
      <h4 class="heading settled" data-level="5.4.1" id="cache-match"><span class="secno">5.4.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-match-method" id="ref-for-cache-match-method-2">match(request, options)</a></code></span><a class="self-link" href="#cache-match"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="method" data-export="" data-lt="match(request, options)|match(request)" id="cache-match-method"><code>match(<var>request</var>, <var>options</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>p</var> be the result of running the algorithm specified in <code class="idl"><a data-link-type="idl" href="#cache-matchall-method" id="ref-for-cache-matchall-method-2">matchAll(request, options)</a></code> method with <var>request</var> and <var>options</var> as the arguments.
         <li>Wait until <var>p</var> settles.
         <li>
          If <var>p</var> rejects with an exception, then: 
          <ol>
           <li>Reject <var>promise</var> with that exception.
          </ol>
         <li>
          Else if <var>p</var> resolves with an array, <var>responseArray</var>, then: 
          <ol>
           <li>
            If <var>responseArray</var> is an empty array, then: 
            <ol>
             <li>Resolve <var>promise</var> with undefined.
            </ol>
           <li>
            Else: 
            <ol>
             <li>Resolve <var>promise</var> with the first element of <var>responseArray</var>.
            </ol>
          </ol>
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-matchall">
      <h4 class="heading settled" data-level="5.4.2" id="cache-matchall"><span class="secno">5.4.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-matchall-method" id="ref-for-cache-matchall-method-3">matchAll(request, options)</a></code></span><a class="self-link" href="#cache-matchall"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="method" data-export="" data-lt="matchAll(request, options)|matchAll(request)|matchAll()" id="cache-matchall-method"><code>matchAll(<var>request</var>, <var>options</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>r</var> be null.
       <li>
        If the optional argument <var>request</var> is not omitted, then: 
        <ol>
         <li>
          If <var>request</var> is a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object, then: 
          <ol>
           <li>Set <var>r</var> to <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>.
           <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-method">method</a> is not `<code>GET</code>` and <var>options</var>.<var>ignoreMethod</var> is false, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolved with an empty array.
          </ol>
         <li>
          Else if <var>request</var> is a string, then: 
          <ol>
           <li>Set <var>r</var> to the associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a> of the result of invoking the initial value of <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> as constructor with <var>request</var> as its argument. If this <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with that exception.
          </ol>
        </ol>
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>responseArray</var> be an empty array.
         <li>
          If the optional argument <var>request</var> is omitted, then: 
          <ol>
           <li>
            For each <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-4">fetching record</a> <var>entry</var> of its <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-3">request to response map</a>, in key insertion order: 
            <ol>
             <li>Add a  copy of <var>entry</var>.[[value]] to <var>responseArray</var>.
            </ol>
           <li>Resolve <var>promise</var> with <var>responseArray</var>.
           <li>Abort these steps.
          </ol>
         <li>
          Else: 
          <ol>
           <li>Let <var>entries</var> be the result of running <a href="#query-cache-algorithm">Query Cache</a> algorithm passing a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object associated with <var>r</var> and <var>options</var> as the arguments.
           <li>
            For each <var>entry</var> of <var>entries</var>: 
            <ol>
             <li>Let <var>response</var> be null.
             <li>If the <a href="#dfn-incumbent-record" id="ref-for-dfn-incumbent-record-1">incumbent record</a> <var>incumbentRecord</var> of the corresponding <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-5">fetching record</a> <var>fetchingRecord</var> in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-4">request to response map</a> is not null, set <var>response</var> to a copy of <var>incumbentRecord</var>.[[value]].
             <li>Else, set <var>response</var> to a copy of <var>entry</var>[1].
             <li>Add <var>response</var> to <var>responseArray</var>.
            </ol>
           <li>Resolve <var>promise</var> with <var>responseArray</var>.
          </ol>
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-add">
      <h4 class="heading settled" data-level="5.4.3" id="cache-add"><span class="secno">5.4.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-add-method" id="ref-for-cache-add-method-2">add(request)</a></code></span><a class="self-link" href="#cache-add"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="method" data-export="" id="cache-add-method"><code>add(<var>request</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>requests</var> be an array containing only <var>request</var>.
       <li>Set <var>responseArrayPromise</var> to the result of running the algorithm specified in <code class="idl"><a data-link-type="idl" href="#cache-addAll-method" id="ref-for-cache-addAll-method-2">addAll(requests)</a></code> passing <var>requests</var> as the argument.
       <li>Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>responseArrayPromise</var> with a fulfillment handler that returns undefined.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-addAll">
      <h4 class="heading settled" data-level="5.4.4" id="cache-addAll"><span class="secno">5.4.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-addAll-method" id="ref-for-cache-addAll-method-3">addAll(requests)</a></code></span><a class="self-link" href="#cache-addAll"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="method" data-export="" id="cache-addAll-method"><code>addAll(<var>requests</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>responsePromiseArray</var> be an empty array.
       <li>Let <var>requestArray</var> be an empty array.
       <li>
        For each <var>request</var> whose type is <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> in <var>requests</var>: 
        <ol>
         <li>Let <var>r</var> be <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>.
         <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", or <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-method">method</a> is not `<code>GET</code>`, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
        </ol>
       <li>
        For each <var>request</var> in <var>requests</var>: 
        <ol>
         <li>Let <var>r</var> be the associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a> of the result of invoking the initial value of <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> as constructor with <var>request</var> as its argument. If this <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with that exception.
         <li>
          If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", then: 
          <ol>
           <li><a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch-terminate">Terminate</a> all the ongoing <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetches</a> initiated by <var>requests</var> with reason <em>fatal</em>.
           <li>Break the loop.
          </ol>
         <li>Set <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-initiator">initiator</a> to "<code>fetch</code>" and <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-destination">destination</a> to "<code>subresource</code>".
         <li>Add a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object associated with <var>r</var> to <var>requestArray</var>.
         <li>Let <var>responsePromise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
         <li>
          Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
          <ul>
           <li><a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">Fetch</a> <var>r</var>.
           <li>
            To <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#process-response">process response</a> for <var>response</var>, run these substeps: 
            <ol>
             <li>If <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-type">type</a> is <em>error</em>, or <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-status">status</a> is not an <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#ok-status">ok status</a>, reject <var>responsePromise</var> with a <code>TypeError</code>.
             <li>
              Else if <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a> contains a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header">header</a> <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header-name">named</a> `<code>Vary</code>`, then: 
              <ol>
               <li>Let <var>varyHeaders</var> be the array containing the elements corresponding to the <a data-link-type="dfn" href="https://tools.ietf.org/html/rfc7230#section-3.2">field-values</a> of the <a data-link-type="dfn" href="https://tools.ietf.org/html/rfc7231#section-7.1.4">Vary</a> header.
               <li>Let <var>matchAsterisk</var> be false.
               <li>
                For each <var>f</var> in <var>varyHeaders</var>: 
                <ol>
                 <li>If <var>f</var> matches "<code>*</code>", set <var>matchAsterisk</var> to true and break the loop.
                </ol>
               <li>If <var>matchAsterisk</var> is true, reject <var>responsePromise</var> with a <code>TypeError</code>.
               <li>Else, resolve <var>responsePromise</var> with a new <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object associated with <var>response</var> and a new <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#headers">Headers</a></code> object whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-headers-guard">guard</a> is "<code>immutable</code>".
              </ol>
             <li>Else, resolve <var>responsePromise</var> with a new <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object associated with <var>response</var> and a new <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#headers">Headers</a></code> object whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-headers-guard">guard</a> is "<code>immutable</code>".
            </ol>
            <p class="note" role="note">This step ensures that the promise for this fetch resolves as soon as the response’s headers become available.</p>
           <li>To <a data-link-type="dfn">process response body</a> for <var>response</var>, do nothing.
           <li>To <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#process-response-end-of-file">process response end-of-file</a> for <var>response</var>, do nothing.
          </ul>
         <li>Add <var>responsePromise</var> to <var>responsePromiseArray</var>.
        </ol>
       <li>Let <var>p</var> be <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#waiting-for-all">waiting for all</a> of <var>responsePromiseArray</var>.
       <li>
        Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>p</var> with a fulfillment handler that, when called with argument <var>responseArray</var>, performs the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>operations</var> be an empty array.
         <li>
          For each <var>response</var> in <var>responseArray</var> with the index <var>index</var>: 
          <ol>
           <li>Let <var>o</var> be an empty object representing a <code class="idl"><a data-link-type="idl" href="#dictdef-cache-cachebatchoperation" id="ref-for-dictdef-cache-cachebatchoperation-1">CacheBatchOperation</a></code> dictionary.
           <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-type" id="ref-for-dom-cachebatchoperation-type-1">type</a></code> dictionary member of <var>o</var> to "put".
           <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-1">request</a></code> dictionary member of <var>o</var> to <var>requestArray</var>[<var>index</var>].
           <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-response" id="ref-for-dom-cachebatchoperation-response-1">response</a></code> dictionary member of <var>o</var> to <var>response</var>.
           <li>Add <var>o</var> to <var>operations</var>.
          </ol>
         <li>Let <var>resultPromise</var> be the result of running <a href="#batch-cache-operations-algorithm">Batch Cache Operations</a> algorithm passing <var>operations</var> as the argument.
         <li>
          Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>resultPromise</var> with a fulfillment handler that, when called with argument <var>responses</var>, performs the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
          <ol>
           <li>Let <var>responseBodyPromiseArray</var> be an empty array.
           <li>
            For each <var>response</var> in <var>responses</var>: 
            <ol>
             <li>Let <var>responseBodyPromise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
             <li>
              Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
              <ol>
               <li>Wait for either end-of-file to have been pushed to <var>response</var>’s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">response</a> <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a> or for <var>r</var> to have a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-termination-reason">termination reason</a>.
               <li>
                If <var>r</var> had a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-termination-reason">termination reason</a>, then: 
                <ol>
                 <li>
                  If the <a href="#dfn-incumbent-record" id="ref-for-dfn-incumbent-record-2">incumbent record</a> <var>incumbentRecord</var> of the corresponding <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-6">fetching record</a> <var>fetchingRecord</var> in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-5">request to response map</a> is not null, then: 
                  <ol>
                   <li>Set <var>fetchingRecord</var> in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-6">request to response map</a> to the copy of <var>incumbentRecord</var>.
                  </ol>
                 <li>
                  Else: 
                  <ol>
                   <li>Delete <var>fetchingRecord</var> from <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-7">request to response map</a>.
                  </ol>
                 <li>Reject <var>responseBodyPromise</var> with a <code>TypeError</code>.
                </ol>
               <li>
                Else: 
                <ol>
                 <li>Set the <a href="#dfn-incumbent-record" id="ref-for-dfn-incumbent-record-3">incumbent record</a> of the corresponding <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-7">fetching record</a> <var>fetchingRecord</var> in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-8">request to response map</a> to the copy of <var>fetchingRecord</var>.
                 <li>Let <var>invalidRecords</var> be the result of running <a href="#query-cache-algorithm">Query Cache</a> algorithm passing <var>fetchingRecord</var>.[[key]] as the argument.
                 <li>
                  For each <var>invalidRecord</var> in <var>invalidRecords</var>: 
                  <ol>
                   <li>If <var>invalidRecord</var> is not <var>fetchingRecord</var>, delete it from <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-9">request to response map</a>.
                  </ol>
                 <li>Resolve <var>responseBodyPromise</var> with <var>response</var>.
                </ol>
              </ol>
             <li>Add <var>responseBodyPromise</var> to <var>responseBodyPromiseArray</var>.
            </ol>
           <li>Let <var>q</var> be <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#waiting-for-all">waiting for all</a> of <var>responseBodyPromiseArray</var>.
           <li>Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>q</var> with a fulfillment handler that returns undefined.
          </ol>
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-put">
      <h4 class="heading settled" data-level="5.4.5" id="cache-put"><span class="secno">5.4.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-put-method" id="ref-for-cache-put-method-2">put(request, response)</a></code></span><a class="self-link" href="#cache-put"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="method" data-export="" id="cache-put-method"><code>put(<var>request</var>, <var>response</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>r</var> be null.
       <li>
        If <var>request</var> is a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object, then: 
        <ol>
         <li>Set <var>r</var> to <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>.
         <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", or <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-method">method</a> is not `<code>GET</code>`, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
        </ol>
       <li>
        Else if <var>request</var> is a string, then: 
        <ol>
         <li>Set <var>r</var> to the associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a> of the result of invoking the initial value of <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> as constructor with <var>request</var> as its argument. If this <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with that exception.
         <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
        </ol>
       <li>
        If <var>response</var>’s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">response</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a> contains a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header">header</a> <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header-name">named</a> `<code>Vary</code>`, then: 
        <ol>
         <li>Let <var>varyHeaders</var> be the array containing the elements corresponding to the <a data-link-type="dfn" href="https://tools.ietf.org/html/rfc7230#section-3.2">field-values</a> of the <a data-link-type="dfn" href="https://tools.ietf.org/html/rfc7231#section-7.1.4">Vary</a> header.
         <li>
          For each <var>f</var> in <var>varyHeaders</var>: 
          <ol>
           <li>If <var>f</var> matches "<code>*</code>", return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
          </ol>
        </ol>
       <li>If <var>response</var> is <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-disturbed">disturbed</a> or <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-locked">locked</a>, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with a <code>TypeError</code>.
       <li>Let <var>newResponse</var> be a new <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> object associated with <var>response</var>’s associated <a href="https://fetch.spec.whatwg.org/#concept-response-response">response</a> and a new <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#headers">Headers</a></code> object whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-headers-guard">guard</a> is <var>response</var>’s <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#headers">Headers</a></code>' <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-headers-guard">guard</a>.
       <li>
        If <var>response</var>’s body is non-null, run these substeps: 
        <ol>
         <li>Let <var>dummyStream</var> be an <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-empty-readablestream">empty</a> <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-readablestream">ReadableStream</a> object.
         <li>Set <var>response</var>’s <a href="https://fetch.spec.whatwg.org/#concept-body-body">body</a> to a new <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a> whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-body-stream">stream</a> is <var>dummyStream</var>.
         <li>Let <var>reader</var> be the result of <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-get-reader">getting a reader</a> from <var>dummyStream</var>.
         <li><a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream">Read all bytes</a> from <var>dummyStream</var> with <var>reader</var>.
        </ol>
       <li>Let <var>operations</var> be an empty array.
       <li>Let <var>o</var> be an empty object representing a <code class="idl"><a data-link-type="idl" href="#dictdef-cache-cachebatchoperation" id="ref-for-dictdef-cache-cachebatchoperation-2">CacheBatchOperation</a></code> dictionary.
       <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-type" id="ref-for-dom-cachebatchoperation-type-2">type</a></code> dictionary member of <var>o</var> to "put".
       <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-2">request</a></code> dictionary member of <var>o</var> to a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object associated with <var>r</var>.
       <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-response" id="ref-for-dom-cachebatchoperation-response-2">response</a></code> dictionary member of <var>o</var> to <var>newResponse</var>.
       <li>Add <var>o</var> to <var>operations</var>.
       <li>Let <var>resultPromise</var> be the result of running <a href="#batch-cache-operations-algorithm">Batch Cache Operations</a> passing <var>operations</var> as the argument.
       <li>
        Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>resultPromise</var> with a fulfillment handler that, when called with argument <var>responses</var>, performs the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Wait for either end-of-file to have been pushed to <var>responses</var>[0]'s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">response</a> <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a> or for <var>r</var> to have a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-termination-reason">termination reason</a>.
         <li>
          If <var>r</var> had a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-termination-reason">termination reason</a>, then: 
          <ol>
           <li>
            If the <a href="#dfn-incumbent-record" id="ref-for-dfn-incumbent-record-4">incumbent record</a> <var>incumbentRecord</var> of the corresponding <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-8">fetching record</a> <var>fetchingRecord</var> in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-10">request to response map</a> is not null, then: 
            <ol>
             <li>Set <var>fetchingRecord</var> in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-11">request to response map</a> to the copy of <var>incumbentRecord</var>.
            </ol>
           <li>
            Else: 
            <ol>
             <li>Delete <var>fetchingRecord</var> from <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-12">request to response map</a>.
            </ol>
           <li><a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">Throw</a> a <code>TypeError</code>.
          </ol>
         <li>
          Else: 
          <ol>
           <li>Set the <a href="#dfn-incumbent-record" id="ref-for-dfn-incumbent-record-5">incumbent record</a> of the corresponding <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-9">fetching record</a> <var>fetchingRecord</var> in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-13">request to response map</a> to the copy of <var>fetchingRecord</var>.
           <li>Let <var>invalidRecords</var> be the result of running <a href="#query-cache-algorithm">Query Cache</a> algorithm passing <var>fetchingRecord</var>.[[key]] as the argument.
           <li>
            For each <var>invalidRecord</var> in <var>invalidRecords</var>: 
            <ol>
             <li>If <var>invalidRecord</var> is not <var>fetchingRecord</var>, delete it from <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-14">request to response map</a>.
            </ol>
           <li>Return undefined.
          </ol>
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-delete">
      <h4 class="heading settled" data-level="5.4.6" id="cache-delete"><span class="secno">5.4.6. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-delete-method" id="ref-for-cache-delete-method-2">delete(request, options)</a></code></span><a class="self-link" href="#cache-delete"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="method" data-export="" data-lt="delete(request, options)|delete(request)" id="cache-delete-method"><code>delete(<var>request</var>, <var>options</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>r</var> be null.
       <li>
        If <var>request</var> is a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object, then: 
        <ol>
         <li>Set <var>r</var> to <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>.
         <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-method">method</a> is not `<code>GET</code>` and <var>options</var>.<var>ignoreMethod</var> is false, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolved with false.
        </ol>
       <li>
        Else if <var>request</var> is a string, then: 
        <ol>
         <li>Set <var>r</var> to the associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a> of the result of invoking the initial value of <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> as constructor with <var>request</var> as its argument. If this <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with that exception.
        </ol>
       <li>Let <var>operations</var> be an empty array.
       <li>Let <var>o</var> be an empty object representing a <code class="idl"><a data-link-type="idl" href="#dictdef-cache-cachebatchoperation" id="ref-for-dictdef-cache-cachebatchoperation-3">CacheBatchOperation</a></code> dictionary.
       <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-type" id="ref-for-dom-cachebatchoperation-type-3">type</a></code> dictionary member of <var>o</var> to "delete".
       <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-3">request</a></code> dictionary member of <var>o</var> to a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object associated with <var>r</var>.
       <li>Set the <code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-options" id="ref-for-dom-cachebatchoperation-options-1">options</a></code> dictionary member of <var>o</var> to <var>options</var>.
       <li>Add <var>o</var> to <var>operations</var>.
       <li>Let <var>resultPromise</var> be the result of running <a href="#batch-cache-operations-algorithm">Batch Cache Operations</a> passing <var>operations</var> as the argument.
       <li>
        Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>resultPromise</var> with a fulfillment handler, when called with argument <var>responseArray</var>, performs the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>If <var>responseArray</var> is not null, return true.
         <li>Else, return false.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-keys">
      <h4 class="heading settled" data-level="5.4.7" id="cache-keys"><span class="secno">5.4.7. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-keys-method" id="ref-for-cache-keys-method-2">keys(request, options)</a></code></span><a class="self-link" href="#cache-keys"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="Cache" data-dfn-type="method" data-export="" data-lt="keys(request, options)|keys(request)|keys()" id="cache-keys-method"><code>keys(<var>request</var>, <var>options</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>promise</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>resultArray</var> be an empty array.
         <li>
          If the optional argument <var>request</var> is omitted, then: 
          <ol>
           <li>
            For each <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-10">fetching record</a> <var>entry</var> of its <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-15">request to response map</a>, in key insertion order: 
            <ol>
             <li>Add <var>entry</var>.[[key]] to <var>resultArray</var>.
            </ol>
          </ol>
         <li>
          Else: 
          <ol>
           <li>Let <var>r</var> be null.
           <li>
            If <var>request</var> is a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object, then: 
            <ol>
             <li>Set <var>r</var> to <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>.
             <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-method">method</a> is not `<code>GET</code>` and <var>options</var>.<var>ignoreMethod</var> is false, resolve <var>promise</var> with an empty array.
            </ol>
           <li>
            Else if <var>request</var> is a string, then: 
            <ol>
             <li>Set <var>r</var> to the associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a> of the result of invoking the initial value of <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> as constructor with <var>request</var> as its argument. If this <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throws</a> an exception, return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> rejected with that exception.
            </ol>
           <li>Let <var>requestResponseArray</var> be the result of running <a href="#query-cache-algorithm">Query Cache</a> algorithm passing a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object that represents <var>r</var> and <var>options</var> as the arguments.
           <li>
            For each <var>requestResponse</var> in <var>requestResponseArray</var>: 
            <ol>
             <li>Add <var>requestResponse</var>[0] to <var>resultArray</var>.
            </ol>
          </ol>
         <li>Resolve <var>promise</var> with <var>resultArray</var>.
        </ol>
       <li>Return <var>promise</var>.
      </ol>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="5.5" id="cache-storage"><span class="secno">5.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-storage-interface" id="ref-for-cache-storage-interface-3">CacheStorage</a></code></span><a class="self-link" href="#cache-storage"></a></h3>
<pre class="idl highlight def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#cache-storage-interface" id="ref-for-cache-storage-interface-4">CacheStorage</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-match-method" id="ref-for-cache-storage-match-method-1">match</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <dfn class="nv idl-code" data-dfn-for="CacheStorage/match(request, options), CacheStorage/match(request)" data-dfn-type="argument" data-export="" id="dom-cachestorage-match-request-options-request">request<a class="self-link" href="#dom-cachestorage-match-request-options-request"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions" id="ref-for-dictdef-cache-cachequeryoptions-6">CacheQueryOptions</a> <dfn class="nv idl-code" data-dfn-for="CacheStorage/match(request, options), CacheStorage/match(request)" data-dfn-type="argument" data-export="" id="dom-cachestorage-match-request-options-options">options<a class="self-link" href="#dom-cachestorage-match-request-options-options"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-has-method" id="ref-for-cache-storage-has-method-1">has</a>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="CacheStorage/has(cacheName)" data-dfn-type="argument" data-export="" id="dom-cachestorage-has-cachename-cachename">cacheName<a class="self-link" href="#dom-cachestorage-has-cachename-cachename"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#cache-interface" id="ref-for-cache-interface-15">Cache</a>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-open-method" id="ref-for-cache-storage-open-method-1">open</a>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="CacheStorage/open(cacheName)" data-dfn-type="argument" data-export="" id="dom-cachestorage-open-cachename-cachename">cacheName<a class="self-link" href="#dom-cachestorage-open-cachename-cachename"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-delete-method" id="ref-for-cache-storage-delete-method-1">delete</a>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="CacheStorage/delete(cacheName)" data-dfn-type="argument" data-export="" id="dom-cachestorage-delete-cachename-cachename">cacheName<a class="self-link" href="#dom-cachestorage-delete-cachename-cachename"></a></dfn>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<span class="kt">DOMString</span>>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-keys-method" id="ref-for-cache-storage-keys-method-1">keys</a>();
};
</pre>
     <p class="note" role="note"><code class="idl"><a data-link-type="idl" href="#cache-storage-interface" id="ref-for-cache-storage-interface-5">CacheStorage</a></code> interface is designed to largely conform to <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-map-objects">ECMAScript 6 Map objects</a> but entirely async, and with additional convenience methods. The methods, <code>clear</code>, <code>forEach</code>, <code>entries</code> and <code>values</code>, are intentionally excluded from the scope of the first version resorting to the ongoing discussion about the async iteration by TC39.</p>
     <p>The user agent <em class="rfc2119" title="MUST">must</em> create a <code class="idl"><a data-link-type="idl" href="#cache-storage-interface" id="ref-for-cache-storage-interface-6">CacheStorage</a></code> object when a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a></code> object or a <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#workerglobalscope">WorkerGlobalScope</a></code> object is created and associate it with that <dfn class="dfn-paneled" data-dfn-for="CacheStorage" data-dfn-type="dfn" data-noexport="" id="cachestorage-global-object">global object</dfn>.</p>
     <p>A <code><dfn class="dfn-paneled idl-code" data-dfn-for="CacheStorage" data-dfn-type="interface" data-export="" id="cache-storage-interface">CacheStorage</dfn></code> object represents a <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-2">name to cache map</a> of its associated <a data-link-type="dfn" href="#cachestorage-global-object" id="ref-for-cachestorage-global-object-1">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>. Multiple separate objects implementing the <code class="idl"><a data-link-type="idl" href="#cache-storage-interface" id="ref-for-cache-storage-interface-7">CacheStorage</a></code> interface across documents and workers can all be associated with the same <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-3">name to cache map</a> simultaneously.</p>
     <section class="algorithm" data-algorithm="cache-storage-match">
      <h4 class="heading settled" data-level="5.5.1" id="cache-storage-match"><span class="secno">5.5.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-storage-match-method" id="ref-for-cache-storage-match-method-2">match(request, options)</a></code></span><a class="self-link" href="#cache-storage-match"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="CacheStorage" data-dfn-type="method" data-export="" data-lt="match(request, options)|match(request)" id="cache-storage-match-method"><code>match(<var>request</var>, <var>options</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>
        If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachequeryoptions-cachename" id="ref-for-dom-cachequeryoptions-cachename-1">cacheName</a></code> is <a data-link-type="dfn" href="https://www.w3.org/TR/WebIDL/#dfn-present">present</a>, then: 
        <ol>
         <li>
          Return a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> <var>p</var> and run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
          <ol>
           <li>
            For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of its <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-4">name to cache map</a>, in key insertion order: 
            <ol>
             <li>
              If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachequeryoptions-cachename" id="ref-for-dom-cachequeryoptions-cachename-2">cacheName</a></code> matches <var>entry</var>.[[key]], then: 
              <ol>
               <li>Resolve <var>p</var> with the result of running the algorithm specified in <code class="idl"><a data-link-type="idl" href="#cache-match-method" id="ref-for-cache-match-method-3">match(request, options)</a></code> method of <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-16">Cache</a></code> interface with <var>request</var> and <var>options</var> as the arguments (providing <var>entry</var>.[[value]] as thisArgument to the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist">[[Call]]</a> internal method of <code class="idl"><a data-link-type="idl" href="#cache-match-method" id="ref-for-cache-match-method-4">match(request, options)</a></code>.)
               <li>Abort these steps.
              </ol>
            </ol>
           <li>Resolve <var>p</var> with undefined.
          </ol>
        </ol>
       <li>
        Else: 
        <ol>
         <li>Let <var>p</var> be a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolved with undefined.
         <li>
          For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of its <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-5">name to cache map</a>, in key insertion order: 
          <ol>
           <li>
            Set <var>p</var> to the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> itself with a fulfillment handler that, when called with argument <var>v</var>, performs the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
            <ol>
             <li>If <var>v</var> is not undefined, return <var>v</var>.
             <li>Return the result of running the algorithm specified in <code class="idl"><a data-link-type="idl" href="#cache-match-method" id="ref-for-cache-match-method-5">match(request, options)</a></code> method of <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-17">Cache</a></code> interface with <var>request</var> and <var>options</var> as the arguments (providing <var>entry</var>.[[value]] as thisArgument to the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist">[[Call]]</a> internal method of <code class="idl"><a data-link-type="idl" href="#cache-match-method" id="ref-for-cache-match-method-6">match(request, options)</a></code>.)
            </ol>
          </ol>
         <li>Return <var>p</var>.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-storage-has">
      <h4 class="heading settled" data-level="5.5.2" id="cache-storage-has"><span class="secno">5.5.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-storage-has-method" id="ref-for-cache-storage-has-method-2">has(cacheName)</a></code></span><a class="self-link" href="#cache-storage-has"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="CacheStorage" data-dfn-type="method" data-export="" id="cache-storage-has-method"><code>has(<var>cacheName</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>
        Return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> <var>p</var> resolved with the result of running the following substeps: 
        <ol>
         <li>
          For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of its <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-6">name to cache map</a>, in key insertion order: 
          <ol>
           <li>
            If <var>cacheName</var> matches <var>entry</var>.[[key]], then: 
            <ol>
             <li>Return true.
            </ol>
          </ol>
         <li>Return false.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-storage-open">
      <h4 class="heading settled" data-level="5.5.3" id="cache-storage-open"><span class="secno">5.5.3. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-storage-open-method" id="ref-for-cache-storage-open-method-2">open(cacheName)</a></code></span><a class="self-link" href="#cache-storage-open"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="CacheStorage" data-dfn-type="method" data-export="" id="cache-storage-open-method"><code>open(<var>cacheName</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>p</var> be a new <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>.
       <li>
        Run the following substeps: 
        <ol>
         <li>
          For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of its <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-7">name to cache map</a>, in key insertion order: 
          <ol>
           <li>
            If <var>cacheName</var> matches <var>entry</var>.[[key]], then: 
            <ol>
             <li>Resolve <var>p</var> with a new <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-18">Cache</a></code> object which is a copy of <var>entry</var>.[[value]].
             <li>Abort these steps.
            </ol>
          </ol>
         <li>Let <var>cache</var> be a new <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-19">Cache</a></code> object.
         <li>Set a newly-created <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]]: <var>cacheName</var>, [[value]]: <var>cache</var>} to <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-8">name to cache map</a>. If this cache write operation failed due to exceeding the granted quota limit, reject <var>p</var> with a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#quotaexceedederror">QuotaExceededError</a></code>" exception and abort these steps.
         <li>Resolve <var>p</var> with <var>cache</var>.
        </ol>
       <li>Return <var>p</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-storage-delete">
      <h4 class="heading settled" data-level="5.5.4" id="cache-storage-delete"><span class="secno">5.5.4. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-storage-delete-method" id="ref-for-cache-storage-delete-method-2">delete(cacheName)</a></code></span><a class="self-link" href="#cache-storage-delete"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="CacheStorage" data-dfn-type="method" data-export="" id="cache-storage-delete-method"><code>delete(<var>cacheName</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <ol>
       <li>Let <var>p</var> be the result of running the algorithm specified in <code class="idl"><a data-link-type="idl" href="#cache-storage-has-method" id="ref-for-cache-storage-has-method-3">has(cacheName)</a></code> method with <var>cacheName</var> as the argument.
       <li>
        Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>p</var> with a fulfillment handler that, when called with argument <var>cacheExists</var>, performs the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>
          If <var>cacheExists</var> is true, then: 
          <ol>
           <li>Delete a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> from its <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-9">name to cache map</a> where <var>cacheName</var> matches entry.[[key]].
           <li>Return true.
           <li>Abort these steps.
          </ol>
          <p class="note" role="note">After this step, the existing DOM objects (i.e. the currently referenced Cache, Request, and Response objects) should remain functional.</p>
         <li>
          Else: 
          <ol>
           <li>Return false.
          </ol>
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="cache-storage-keys">
      <h4 class="heading settled" data-level="5.5.5" id="cache-storage-keys"><span class="secno">5.5.5. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#cache-storage-keys-method" id="ref-for-cache-storage-keys-method-2">keys()</a></code></span><a class="self-link" href="#cache-storage-keys"></a></h4>
      <p><dfn class="dfn-paneled idl-code" data-dfn-for="CacheStorage" data-dfn-type="method" data-export="" id="cache-storage-keys-method"><code>keys()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps:</p>
      <p class="note" role="note">The promise returned from this method resolves with the sequence of keys, cache names in DOMString, in insertion order.</p>
      <ol>
       <li>Let <var>resultArray</var> be an empty array.
       <li>
        Return a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> <var>p</var> resolved with the result of running the following substeps: 
        <ol>
         <li>
          For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of its <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-10">name to cache map</a>, in key insertion order: 
          <ol>
           <li>Add <var>entry</var>.[[key]] to <var>resultArray</var>.
          </ol>
         <li>Return <var>resultArray</var>.
        </ol>
      </ol>
     </section>
    </section>
   </section>
   <section>
    <h2 class="heading settled" data-level="6" id="security-considerations"><span class="secno">6. </span><span class="content">Security Considerations</span><a class="self-link" href="#security-considerations"></a></h2>
    <section>
     <h3 class="heading settled" data-level="6.1" id="secure-context"><span class="secno">6.1. </span><span class="content">Secure Context</span><a class="self-link" href="#secure-context"></a></h3>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-75">Service workers</a> <em class="rfc2119" title="MUST">must</em> execute in <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure contexts</a>. <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-31">Service worker clients</a> <em class="rfc2119" title="MUST">must</em> also be <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure contexts</a> to register a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-43">service worker registration</a>, to get access to the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-44">service worker registrations</a> and the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-76">service workers</a>, to do messaging with the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-77">service workers</a>, and to be manipulated by the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-78">service workers</a>. This effectively means that <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-79">service workers</a> and their <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-32">service worker clients</a> <em class="rfc2119" title="SHOULD">should</em> be hosted over HTTPS. A user agent <em class="rfc2119" title="MAY">may</em> allow <code>localhost</code>, <code>127.0.0.0/8</code>, and <code>::1/128</code> for development purpose. (Note that they may still be <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure contexts</a>.) The primary reason for this restriction is to protect users from the <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#threat-risks">risks associated with insecure contexts</a>.</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="6.2" id="content-security-policy"><span class="secno">6.2. </span><span class="content">Content Security Policy</span><a class="self-link" href="#content-security-policy"></a></h3>
     <p>Whenever a user agent invokes <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-80">service worker</a> <var>serviceWorker</var>: </p>
     <ul>
      <li>If <var>serviceWorker</var>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-3">script resource</a> was delivered with a <code>Content-Security-Policy</code> HTTP header containing the value <var>policy</var>, the user agent <em class="rfc2119" title="MUST">must</em> <a data-link-type="dfn" href="https://w3c.github.io/webappsec-csp/2/#enforce">enforce</a> <var>policy</var> for <var>serviceWorker</var>.
      <li>If <var>serviceWorker</var>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-4">script resource</a> was delivered with a <code>Content-Security-Policy-Report-Only</code> HTTP header containing the value <var>policy</var>, the user agent <em class="rfc2119" title="MUST">must</em> <a data-link-type="dfn" href="https://w3c.github.io/webappsec-csp/2/#monitor">monitor</a> <var>policy</var> for <var>serviceWorker</var>.
     </ul>
     <p></p>
     <p>The primary reason for this restriction is to mitigate a broad class of content injection vulnerabilities, such as cross-site scripting (XSS).</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="6.3" id="origin-relativity"><span class="secno">6.3. </span><span class="content">Origin Relativity</span><a class="self-link" href="#origin-relativity"></a></h3>
     <section>
      <h4 class="heading settled" data-level="6.3.1" id="origin-restriction"><span class="secno">6.3.1. </span><span class="content">Origin restriction</span><a class="self-link" href="#origin-restriction"></a></h4>
      <p><em>This section is non-normative.</em></p>
      <p>A <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-81">Service worker</a> executes in the registering <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-33">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>. One of the advanced concerns that major applications would encounter is whether they can be hosted from a CDN. By definition, these are servers in other places, often on other <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origins</a>. Therefore, <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-82">service workers</a> cannot be hosted on CDNs. But they can include resources via <a href="#importscripts-method" id="ref-for-importscripts-method-1">importScripts()</a>. The reason for this restriction is that <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-83">service workers</a> create the opportunity for a bad actor to turn a bad day into a bad eternity.</p>
     </section>
     <section>
      <h4 class="heading settled" data-level="6.3.2" id="importscripts"><span class="secno">6.3.2. </span><span class="content"><code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts">importScripts(urls)</a></code></span><a class="self-link" href="#importscripts"></a></h4>
      <p>When the <dfn class="dfn-paneled idl-code" data-dfn-for="ServiceWorkerGlobalScope" data-dfn-type="method" data-export="" id="importscripts-method"><code>importScripts(<var>urls</var>)</code></dfn> method is called on a <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-12">ServiceWorkerGlobalScope</a></code> object, the user agent <em class="rfc2119" title="MUST">must</em> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#import-scripts-into-worker-global-scope">import scripts into worker global scope</a>, given this <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-13">ServiceWorkerGlobalScope</a></code> object and <var>urls</var>, and with the following steps to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-perform-fetch">perform the fetch</a> given the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request">request</a> <var>request</var>:</p>
      <ol>
       <li>Let <var>serviceWorker</var> be <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-client">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-19">service worker</a>.
       <li>
        If <var>serviceWorker</var>’s <a href="#dfn-imported-scripts-updated-flag" id="ref-for-dfn-imported-scripts-updated-flag-1">imported scripts updated flag</a> is unset, then: 
        <ol>
         <li>Let <var>response</var> be the result of <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetching</a> <var>request</var>.
         <li>
          If <var>response</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#unsafe-response">unsafe response</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-type">type</a> is not "<code>error</code>", and <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-status">status</a> is an <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#ok-status">ok status</a>, then: 
          <ol>
           <li>If there exists a corresponding Record <var>record</var> for <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a> in <var>serviceWorker</var>’s <a href="#dfn-script-resource-map" id="ref-for-dfn-script-resource-map-1">script resource map</a>, set <var>record</var>.[[value]] to <var>response</var>.
           <li>Else, set a newly-created Record {[[key]]: <var>url</var>, [[value]]: <var>response</var>} to <var>serviceWorker</var>’s <a href="#dfn-script-resource-map" id="ref-for-dfn-script-resource-map-2">script resource map</a>.
          </ol>
         <li>Return <var>response</var>. 
        </ol>
       <li>
        Else: 
        <ol>
         <li>If there exists a corresponding Record <var>record</var> for <var>url</var> in <var>serviceWorker</var>’s <a href="#dfn-script-resource-map" id="ref-for-dfn-script-resource-map-3">script resource map</a>, return <var>record</var>.[[value]].
         <li>Else, return a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a>.
        </ol>
      </ol>
     </section>
    </section>
    <section>
     <h3 class="heading settled" data-level="6.4" id="cross-origin-resources"><span class="secno">6.4. </span><span class="content">Cross-Origin Resources and CORS</span><a class="self-link" href="#cross-origin-resources"></a></h3>
     <p><em>This section is non-normative.</em></p>
     <p>Applications tend to cache items that come from a CDN or other <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>. It is possible to request many of them directly using <code>&lt;script></code>, <code>&lt;img></code>, <code>&lt;video></code> and <code>&lt;link></code> elements. It would be hugely limiting if this sort of runtime collaboration broke when offline. Similarly, it is possible to <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> many sorts of off-<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> resources when appropriate CORS headers are set.</p>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-84">Service workers</a> enable this by allowing <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-20">Caches</a></code> to <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> and cache off-origin items. Some restrictions apply, however. First, unlike same-origin resources which are managed in the <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-21">Cache</a></code> as <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> objects whose corresponding <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">responses</a> are <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-filtered-response-basic">basic filtered response</a>, the objects stored are <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> objects whose corresponding <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">responses</a> are either <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-filtered-response-cors">CORS filtered responses</a> or <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque">opaque filtered responses</a>. They can be passed to <code class="idl"><a data-link-type="idl" href="#fetch-event-respondwith-method" id="ref-for-fetch-event-respondwith-method-4">event.respondWith(r)</a></code> method in the same manner as the <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> objects whose corresponding <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">responses</a> are <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-filtered-response-basic">basic filtered responses</a>, but cannot be meaningfully created programmatically. These limitations are necessary to preserve the security invariants of the platform. Allowing <code class="idl"><a data-link-type="idl" href="#cache-interface" id="ref-for-cache-interface-22">Caches</a></code> to store them allows applications to avoid re-architecting in most cases.</p>
    </section>
    <section>
     <h3 class="heading settled" data-level="6.5" id="implementer-concerns"><span class="secno">6.5. </span><span class="content">Implementer Concerns</span><a class="self-link" href="#implementer-concerns"></a></h3>
     <p><em>This section is non-normative.</em></p>
     <p>The implementers are encouraged to note: </p>
     <ul>
      <li>Plug-ins should not load via <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-85">service workers</a>. As plug-ins may get their security origins from their own urls, the embedding <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-86">service worker</a> cannot handle it. For this reason, the <a href="#on-fetch-request-algorithm">Handle Fetch</a> algorithm makes the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#potential-navigation-or-subresource-request">potential-navigation-or-subresource request</a> (whose context is either <code>&lt;embed></code> or <code>&lt;object></code>) immediately fallback to the network without dispatching <a href="#service-worker-global-scope-fetch-event" id="ref-for-service-worker-global-scope-fetch-event-6">fetch</a> event.
      <li>Some of the legacy networking stack code may need to be carefully audited to understand the ramifications of interactions with <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-87">service workers</a>.
     </ul>
     <p></p>
    </section>
    <section>
     <h3 class="heading settled" data-level="6.6" id="privacy"><span class="secno">6.6. </span><span class="content">Privacy</span><a class="self-link" href="#privacy"></a></h3>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-88">Service workers</a> introduce new persistent storage features including <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-6">scope to registration map</a> (for <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-45">service worker registrations</a> and their <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-89">service workers</a>), <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-16">request to response map</a> and <a href="#dfn-name-to-cache-map" id="ref-for-dfn-name-to-cache-map-11">name to cache map</a> (for caches), and <a href="#dfn-script-resource-map" id="ref-for-dfn-script-resource-map-4">script resource map</a> (for script resources). In order to protect users from any potential <a data-link-type="biblio" href="#biblio-unsanctioned-tracking">unsanctioned tracking</a> threat, these persistent storages <em class="rfc2119" title="SHOULD">should</em> be cleared when users intend to clear them and <em class="rfc2119" title="SHOULD">should</em> maintain and interoperate with existing user controls e.g. purging all existing persistent storages.</p>
    </section>
   </section>
   <section>
    <h2 class="heading settled" data-level="7" id="storage-considerations"><span class="secno">7. </span><span class="content">Storage Considerations</span><a class="self-link" href="#storage-considerations"></a></h2>
    <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-90">Service workers</a> <em class="rfc2119" title="SHOULD">should</em> take a dependency on <a data-link-type="biblio" href="#biblio-quota-api">Quota Management API</a> that <a href="http://www.w3.org/TR/quota-api/#extensions-to-the-serviceworkerglobalscope-interface">extends the ServiceWorkerGlobalScope</a> with the event listeners <code class="idl"><a data-link-type="idl" href="http://www.w3.org/TR/quota-api/#widl-ServiceWorkerGlobalScope-onbeforeevicted">onbeforeevicted</a></code> and <code class="idl"><a data-link-type="idl" href="http://www.w3.org/TR/quota-api/#widl-ServiceWorkerGlobalScope-onevicted">onevicted</a></code> to detect a storage pressure and give pre-eviction information to the application.</p>
    <p>The cache write operations in <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-91">service workers</a> when failed due to exceeding the granted quota limit <em class="rfc2119" title="SHOULD">should</em> throw "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#quotaexceedederror">QuotaExceededError</a></code>" exception.</p>
    <section>
     <h2 class="heading settled" data-level="8" id="extensibility"><span class="secno">8. </span><span class="content">Extensibility</span><a class="self-link" href="#extensibility"></a></h2>
     <p><a href="#dfn-service-worker" id="ref-for-dfn-service-worker-92">Service workers</a> are extensible from other specifications.</p>
     <section>
      <h3 class="heading settled" data-level="8.1" id="extension-to-service-worker-registration"><span class="secno">8.1. </span><span class="content">Define API bound to Service Worker Registration</span><a class="self-link" href="#extension-to-service-worker-registration"></a></h3>
      <p>Specifications <em class="rfc2119" title="MAY">may</em> define an API tied to a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-46">service worker registration</a> by using <a data-link-type="dfn" href="https://www.w3.org/TR/WebIDL/#dfn-partial-interface">partial interface</a> definition to the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-16">ServiceWorkerRegistration</a></code> interface where it <em class="rfc2119" title="MAY">may</em> define the specification specific attributes and methods:</p>
<pre class="example idl highlight def" data-no-idl="" id="example-570ccfd8"><a class="self-link" href="#example-570ccfd8"></a><span class="kt">partial</span> <span class="kt">interface</span> <span class="nv">ServiceWorkerRegistration</span> {
  // e.g. define an API namespace
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="n">APISpaceType</span> <span class="nv">APISpace</span>;
  // e.g. define a method
  <span class="kt">Promise</span>&lt;<span class="n">T</span>> <span class="nv">methodName</span>(/* list of arguments */);
};
</pre>
     </section>
     <section>
      <h3 class="heading settled" data-level="8.2" id="extension-to-extendable-event"><span class="secno">8.2. </span><span class="content">Define Functional Event</span><a class="self-link" href="#extension-to-extendable-event"></a></h3>
      <p>Specifications <em class="rfc2119" title="MAY">may</em> define a <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-5">functional event</a> by extending <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-13">ExtendableEvent</a></code> interface:</p>
<pre class="example idl highlight def" data-no-idl="" id="example-3de376f0"><a class="self-link" href="#example-3de376f0"></a>// e.g. define FunctionalEvent interface
<span class="kt">interface</span> <span class="nv">FunctionalEvent</span> : <span class="n">ExtendableEvent</span> {
  // add a functional event’s own attributes and methods
};
</pre>
     </section>
     <section>
      <h3 class="heading settled" data-level="8.3" id="extension-to-service-worker-global-scope"><span class="secno">8.3. </span><span class="content">Define Event Handler</span><a class="self-link" href="#extension-to-service-worker-global-scope"></a></h3>
      <p>Specifications <em class="rfc2119" title="MAY">may</em> define an event handler attribute for the corresponding <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-6">functional event</a> using <a data-link-type="dfn" href="https://www.w3.org/TR/WebIDL/#dfn-partial-interface">partial interface</a> definition to the <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-14">ServiceWorkerGlobalScope</a></code> interface:</p>
<pre class="example idl highlight def" data-no-idl="" id="example-8148d1c6"><a class="self-link" href="#example-8148d1c6"></a><span class="kt">partial</span> <span class="kt">interface</span> <span class="nv">ServiceWorkerGlobalScope</span> {
  <span class="kt">attribute</span> <span class="n">EventHandler</span> <span class="nv">on</span><em><span class="nv">functionalevent</span></em>;
};
</pre>
     </section>
     <section>
      <h3 class="heading settled" data-level="8.4" id="request-functional-event-dispatch"><span class="secno">8.4. </span><span class="content">Request Functional Event Dispatch</span><a class="self-link" href="#request-functional-event-dispatch"></a></h3>
      <p>To request a <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-7">functional event</a> dispatch to a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-93">service worker</a>, specifications <em class="rfc2119" title="MAY">may</em> invoke <a href="#handle-functional-event-algorithm">Handle Functional Event</a> algorithm with its <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-47">service worker registration</a> <var>registration</var> and the algorithm <var>callbackSteps</var> as the arguments.</p>
      <p>Specifications <em class="rfc2119" title="MAY">may</em> define an algorithm <var>callbackSteps</var> where the corresponding <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-8">functional event</a> can be created and fired with specification specific objects. The algorithm is passed <var>globalObject</var> (a <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-15">ServiceWorkerGlobalScope</a></code> object) at which it <em class="rfc2119" title="MAY">may</em> fire its <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-9">functional events</a>. This algorithm is called on a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">task</a> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queued</a> by <a href="#handle-functional-event-algorithm">Handle Functional Event</a> algorithm.</p>
      <p class="note" role="note">See an <a href="https://notifications.spec.whatwg.org/#activating-a-notification">example</a> hook defined in <a data-link-type="biblio" href="#biblio-notifications">Notifications API</a>.</p>
     </section>
    </section>
    <section>
     <h2 class="heading settled" id="algorithms"><span class="content">Appendix A: Algorithms</span><a class="self-link" href="#algorithms"></a></h2>
     <p>The following definitions are the user agent’s internal data structures used throughout the specification.</p>
     <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-scope-to-registration-map">scope to registration map</dfn> is a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">List</a> of the <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} where [[key]] is a string that represents a <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-11">scope url</a> and [[value]] is a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-48">service worker registration</a>.</p>
     <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job">job</dfn> is an abstraction of one of register, update, and unregister request for a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-49">service worker registration</a>.</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-1">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-type">job type</dfn>, which is one of <em>register</em>, <em>update</em>, and <em>unregister</em>.</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-2">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-scope-url">scope url</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>).</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-3">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-script-url">script url</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>).</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-4">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-worker-type">worker type</dfn> ("<code>classic</code>" or "<code>module</code>").</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-5">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-client">client</dfn> (a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-34">service worker client</a>). It is initially null.</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-6">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="job promise" data-noexport="" id="dfn-job-promise">promise</dfn> (a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>). It is initially null.</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-7">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-list-of-equivalent-jobs">list of equivalent jobs</dfn> (a list of <a href="#dfn-job" id="ref-for-dfn-job-8">jobs</a>). It is initially the empty list.</p>
     <p>A <a href="#dfn-job" id="ref-for-dfn-job-9">job</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-force-bypass-cache-flag">force bypass cache flag</dfn> It is initially unset.</p>
     <p>Two <a href="#dfn-job" id="ref-for-dfn-job-10">jobs</a> are <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-equivalent">equivalent</dfn> when their <a href="#dfn-job-type" id="ref-for-dfn-job-type-1">job type</a> is the same and: </p>
     <ul>
      <li>For <em>register</em> and <em>update</em> <a href="#dfn-job" id="ref-for-dfn-job-11">jobs</a>, both their <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-1">scope url</a> and the <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-1">script url</a> are the same.
      <li>For <em>unregister</em> <a href="#dfn-job" id="ref-for-dfn-job-12">jobs</a>, their <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-2">scope url</a> is the same.
     </ul>
     <p></p>
     <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job-queue">job queue</dfn> is a thread safe queue used to synchronize the set of concurrent <a href="#dfn-job" id="ref-for-dfn-job-13">jobs</a>. The <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-1">job queue</a> contains <a href="#dfn-job" id="ref-for-dfn-job-14">jobs</a> as its elements. The <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-2">job queue</a> <em class="rfc2119" title="SHOULD">should</em> satisfy the general properties of FIFO queue. A user agent <em class="rfc2119" title="MUST">must</em> maintain a separate <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-3">job queue</a> for each <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-50">service worker registration</a> keyed by its <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-12">scope url</a>. A <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-4">job queue</a> is initially empty. Unless stated otherwise, the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-5">job queue</a> referenced from the algorithm steps is a <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-6">job queue</a> for the <a href="#dfn-job" id="ref-for-dfn-job-15">job</a>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-3">scope url</a>.</p>
     <section class="algorithm" data-algorithm="create-job-algorithm">
      <h3 class="heading settled" id="create-job-algorithm"><span class="content">Create Job</span><a class="self-link" href="#create-job-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>jobType</var>, a <a href="#dfn-job-type" id="ref-for-dfn-job-type-2">job type</a>
       <dd><var>scopeURL</var>, a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>
       <dd><var>scriptURL</var>, a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>
       <dd><var>promise</var>, a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>
       <dd><var>client</var>, a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-35">service worker client</a>
       <dt>Output
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-16">job</a>
      </dl>
      <ol>
       <li>Let <var>job</var> be a new <a href="#dfn-job" id="ref-for-dfn-job-17">job</a>.
       <li>Set <var>job</var>’s <a href="#dfn-job-type" id="ref-for-dfn-job-type-3">job type</a> to <var>jobType</var>.
       <li>Set <var>job</var>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-4">scope url</a> to <var>scopeURL</var>.
       <li>Set <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-2">script url</a> to <var>scriptURL</var>.
       <li>Set <var>job</var>’s <a href="#dfn-job-promise" id="ref-for-dfn-job-promise-1">promise</a> to <var>promise</var>.
       <li>Set <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-1">client</a> to <var>client</var>.
       <li>Return <var>job</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="schedule-job-algorithm">
      <h3 class="heading settled" id="schedule-job-algorithm"><span class="content">Schedule Job</span><a class="self-link" href="#schedule-job-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-18">job</a>
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li>
        If the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-7">job queue</a> is empty, then: 
        <ol>
         <li>Push <var>job</var> to the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-8">job queue</a> and invoke <a href="#run-job-algorithm">Run Job</a>.
        </ol>
       <li>
        Else: 
        <ol>
         <li>Let <var>lastJob</var> be the element at the back of the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-9">job queue</a>.
         <li>If <var>job</var> is <a href="#dfn-job-equivalent" id="ref-for-dfn-job-equivalent-1">equivalent</a> to <var>lastJob</var> and <var>lastJob</var>’s <a href="#dfn-job-promise" id="ref-for-dfn-job-promise-2">promise</a> has not settled, append <var>job</var> to <var>lastJob</var>’s <a href="#dfn-job-list-of-equivalent-jobs" id="ref-for-dfn-job-list-of-equivalent-jobs-1">list of equivalent jobs</a>.
         <li>Else, push <var>job</var> to the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-10">job queue</a>.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="run-job-algorithm">
      <h3 class="heading settled" id="run-job-algorithm"><span class="content">Run Job</span><a class="self-link" href="#run-job-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd>none
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li><a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-11">job queue</a> is not empty.
       <li>
        <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to run these steps: 
        <ol>
         <li>Let <var>job</var> be the element in the front of the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-12">job queue</a>.
         <li>If <var>job</var>’s <a href="#dfn-job-type" id="ref-for-dfn-job-type-4">job type</a> is <em>register</em>, run <a href="#register-algorithm">Register</a> with <var>job</var> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>.
         <li>
          Else if <var>job</var>’s <a href="#dfn-job-type" id="ref-for-dfn-job-type-5">job type</a> is <em>update</em>, run <a href="#update-algorithm">Update</a> with <var>job</var> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>. 
          <p class="note" role="note">For a register job and an update job, the user agent delays queuing a task for running the job until after the document initiated the job has been dispatched <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/indices.html#event-domcontentloaded">DOMContentLoaded</a></code> event.</p>
         <li>Else if <var>job</var>’s <a href="#dfn-job-type" id="ref-for-dfn-job-type-6">job type</a> is <em>unregister</em>, run <a href="#unregister-algorithm">Unregister</a> with <var>job</var> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="finish-job-algorithm">
      <h3 class="heading settled" id="finish-job-algorithm"><span class="content">Finish Job</span><a class="self-link" href="#finish-job-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-19">job</a>
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li><a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: the top element in the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-13">job queue</a> is <var>job</var>.
       <li>Pop the top element from the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-14">job queue</a>.
       <li>If the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-15">job queue</a> is not empty, invoke <a href="#run-job-algorithm">Run Job</a> with the top element of the <a href="#dfn-job-queue" id="ref-for-dfn-job-queue-16">job queue</a>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="resolve-job-promise-algorithm">
      <h3 class="heading settled" id="resolve-job-promise-algorithm"><span class="content">Resolve Job Promise</span><a class="self-link" href="#resolve-job-promise-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-20">job</a>
       <dd><var>value</var>, any
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li>If <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-2">client</a> is not null, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue a task</a> to resolve <var>job</var>’s <a href="#dfn-job-promise" id="ref-for-dfn-job-promise-3">promise</a> with <var>value</var> on <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-3">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a> as the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a>.
       <li>
        For each <var>equivalentJob</var> in <var>job</var>’s <a href="#dfn-job-list-of-equivalent-jobs" id="ref-for-dfn-job-list-of-equivalent-jobs-2">list of equivalent jobs</a>: 
        <ol>
         <li>If <var>equivalentJob</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-4">client</a> is not null, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue a task</a> to resolve <var>equivalentJob</var>’s <a href="#dfn-job-promise" id="ref-for-dfn-job-promise-4">promise</a> with <var>value</var> on <var>equivalentJob</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-5">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a> as the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a>.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="reject-job-promise-algorithm">
      <h3 class="heading settled" id="reject-job-promise-algorithm"><span class="content">Reject Job Promise</span><a class="self-link" href="#reject-job-promise-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-21">job</a>
       <dd><var>reason</var>, an <a data-link-type="dfn" href="https://www.w3.org/TR/WebIDL/#dfn-exception">exception</a>
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li>If <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-6">client</a> is not null, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue a task</a> to reject <var>job</var>’s <a href="#dfn-job-promise" id="ref-for-dfn-job-promise-5">promise</a> with <var>reason</var> on <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-7">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a> as the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a>.
       <li>
        For each <var>equivalentJob</var> in <var>job</var>’s <a href="#dfn-job-list-of-equivalent-jobs" id="ref-for-dfn-job-list-of-equivalent-jobs-3">list of equivalent jobs</a>: 
        <ol>
         <li>If <var>equivalentJob</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-8">client</a> is not null, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue a task</a> to reject <var>equivalentJob</var>’s <a href="#dfn-job-promise" id="ref-for-dfn-job-promise-6">promise</a> with <var>reason</var> on <var>equivalentJob</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-9">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> using the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a> as the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a>.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="register-algorithm">
      <h3 class="heading settled" id="register-algorithm"><span class="content">Register</span><a class="self-link" href="#register-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-22">job</a>
       <dt>Output
       <dd><var>promise</var>, a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>
      </dl>
      <ol>
       <li>
        If the result of running <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#is-origin-trustworthy">Is origin potentially trustworthy</a> with the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-3">script url</a> as the argument is <code>Not Trusted</code>, then: 
        <ol>
         <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>
        If the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-4">script url</a> is not <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-10">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>, then: 
        <ol>
         <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>
        If the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of <var>job</var>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-5">scope url</a> is not <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-11">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>, then: 
        <ol>
         <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>Let <var>registration</var> be the result of running the <a href="#get-registration-algorithm">Get Registration</a> algorithm passing <var>job</var>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-6">scope url</a> as the argument.
       <li>
        If <var>registration</var> is not null, then: 
        <ol>
         <li>If <var>registration</var>’s <a href="#dfn-uninstalling-flag" id="ref-for-dfn-uninstalling-flag-2">uninstalling flag</a> is set, unset it.
         <li>Let <var>newestWorker</var> be the result of running the <a href="#get-newest-worker-algorithm">Get Newest Worker</a> algorithm passing <var>registration</var> as the argument.
         <li>
          If <var>newestWorker</var> is not null and <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-5">script url</a> <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-equals">equals</a> <var>newestWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-3">script url</a> with the <em>exclude fragments flag</em> set, then: 
          <ol>
           <li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-17">ServiceWorkerRegistration</a></code> object which represents <var>registration</var>.
           <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
          </ol>
        </ol>
       <li>
        Else: 
        <ol>
         <li>Invoke <a href="#set-registration-algorithm">Set Registration</a> algorithm passing <var>job</var>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-7">scope url</a> as its argument.
        </ol>
       <li>Invoke <a href="#update-algorithm">Update</a> algorithm passing <var>job</var> as the argument.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="update-algorithm">
      <h3 class="heading settled" id="update-algorithm"><span class="content">Update</span><a class="self-link" href="#update-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-23">job</a>
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li>Let <var>registration</var> be the result of running the <a href="#get-registration-algorithm">Get Registration</a> algorithm passing <var>job</var>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-8">scope url</a> as the argument.
       <li>
        If <var>registration</var> is null or <var>registration</var>’s <a href="#dfn-uninstalling-flag" id="ref-for-dfn-uninstalling-flag-3">uninstalling flag</a> is set, then: 
        <ol>
         <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a <code>TypeError</code>.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>Let <var>newestWorker</var> be the result of running <a href="#get-newest-worker-algorithm">Get Newest Worker</a> algorithm passing <var>registration</var> as the argument.
       <li>
        If <var>job</var>’s <a href="#dfn-job-type" id="ref-for-dfn-job-type-7">job type</a> is <em>update</em>, and <var>newestWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-4">script url</a> does not <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-equals">equal</a> <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-6">script url</a> with the <em>exclude fragments flag</em> set, then: 
        <ol>
         <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a <code>TypeError</code>.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>
        Switching on <var>job</var>’s <a data-link-type="dfn" href="#dfn-job-worker-type" id="ref-for-dfn-job-worker-type-2">worker type</a>, run these substeps with the following options: 
        <dl>
         <dt><em>"<code>classic</code>"</em>
         <dd>
          <p><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script">Fetch a classic worker script</a> given <var>job</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-7">script url</a>, <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-12">client</a>, and "<code>serviceworker</code>".</p>
         <dt><em>"<code>module</code>"</em>
         <dd>
          <p><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-worker-script-tree">Fetch a module worker script tree</a> given <var>job</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-8">script url</a>, <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-13">client</a>, "<code>serviceworker</code>", "<code>omit</code>", and the to-be-created <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a> for this service worker.</p>
        </dl>
        <p>To <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-perform-fetch">perform the fetch</a> given <var>request</var>, run the following steps if the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-top-level">is top-level</a> flag is set:</p>
        <ol>
         <li>
          Append `<code>Service-Worker</code>`/`<code>script</code>` to <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-header-list">header list</a>. 
          <p class="note" role="note">See the definition of the Service-Worker header in Appendix B: Extended HTTP headers.</p>
         <li>Set <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#skip-service-worker-flag">skip service worker flag</a> and <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-redirect-mode">redirect mode</a> to "<code>error</code>".
         <li>
          If <var>newestWorker</var> is not null and <var>registration</var>’s <a href="#dfn-last-update-check-time" id="ref-for-dfn-last-update-check-time-1">last update check time</a> is not null, then: 
          <ol>
           <li>If the time difference in seconds calculated by the current time minus <var>registration</var>’s <a href="#dfn-last-update-check-time" id="ref-for-dfn-last-update-check-time-2">last update check time</a> is greater than 86400, or <em>force bypass cache flag</em> is set, set <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-cache-mode">cache mode</a> to "<code>reload</code>".
          </ol>
          <p class="note" role="note">Even if the cache mode is not set to "reload", the user agent obeys Cache-Control header’s max-age value in the network layer to determine if it should bypass the browser cache.</p>
         <li><a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">Fetch</a> <var>request</var>, and asynchronously wait to run the remaining steps as part of fetch’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#process-response">process response</a> for the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response">response</a> <var>response</var>.
         <li>
          <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type">Extract a MIME type</a> from the <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a>. If this MIME type (ignoring parameters) is not one of <code>text/javascript</code>, <code>application/x-javascript</code>, and <code>application/javascript</code>, then: 
          <ol>
           <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.
           <li>Asynchronously complete these steps with a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a>.
          </ol>
         <li>
          Let <var>serviceWorkerAllowed</var> be the result of <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header-parse">parsing</a> `<code>Service-Worker-Allowed</code>` in <var>response</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a>. 
          <p class="note" role="note">See the definition of the Service-Worker-Allowed header in Appendix B: Extended HTTP headers.</p>
         <li>
          If <var>serviceWorkerAllowed</var> is failure, then: 
          <ol>
           <li>Asynchronously complete these steps with a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a>.
          </ol>
         <li>Let <var>scopeURL</var> be <var>registration</var>’s <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-13">scope url</a>.
         <li>Let <var>maxScopeString</var> be null.
         <li>
          If <var>serviceWorkerAllowed</var> is null, then: 
          <ol>
           <li>Set <var>maxScopeString</var> to "<code>/</code>" concatenated with the strings, except the last string that denotes the script’s file name, in <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-9">script url</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> (including empty strings), separated from each other by "<code>/</code>".
          </ol>
         <li>
          Else: 
          <ol>
           <li>Let <var>maxScope</var> be the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>serviceWorkerAllowed</var> with <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-10">script url</a>.
           <li>Set <var>maxScopeString</var> to "<code>/</code>" concatenated with the strings in <var>maxScope</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> (including empty strings), separated from each other by "<code>/</code>".
          </ol>
         <li>Let <var>scopeString</var> be "<code>/</code>" concatenated with the strings in <var>scopeURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> (including empty strings), separated from each other by "<code>/</code>".
         <li>If <var>scopeString</var> starts with <var>maxScopeString</var>, do nothing.
         <li>
          Else: 
          <ol>
           <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.
           <li>Asynchronously complete these steps with a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a>.
          </ol>
         <li>
          If <var>response</var>’s <a href="https://github.com/whatwg/fetch/issues/376">cache state</a> is not "<code>local</code>", set <var>registration</var>’s <a href="#dfn-last-update-check-time" id="ref-for-dfn-last-update-check-time-3">last update check time</a> to the current time. 
          <p class="issue" id="issue-3c7457a0"><a class="self-link" href="#issue-3c7457a0"></a>The response’s cache state concept had been removed from fetch. The fetch issue <a href="https://github.com/whatwg/fetch/issues/376">#376</a> tracks the request to restore the concept or add some similar way to check this state.</p>
         <li>Return true.
        </ol>
        <p>If the algorithm asynchronously completes with null, then: </p>
        <ol>
         <li>
          <p>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a <code>TypeError</code>.</p>
          <p class="note" role="note">This will do nothing if <a href="#reject-job-promise-algorithm">Reject Job Promise</a> was previously invoked with a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.</p>
         <li>If <var>newestWorker</var> is null, invoke <a href="#clear-registration-algorithm">Clear Registration</a> algorithm passing <var>registration</var> as its argument.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
        <p></p>
        <p>Else, continue the rest of these steps after the algorithm’s asynchronous completion, with <var>script</var> being the asynchronous completion value.</p>
       <li>
        If <var>newestWorker</var> is not null, <var>newestWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-5">script url</a> <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-equals">equals</a> <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-11">script url</a> with the <em>exclude fragments flag</em> set, and <var>script</var> is a byte-for-byte match with <var>newestWorker</var>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-5">script resource</a>, then: 
        <ol>
         <li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-18">ServiceWorkerRegistration</a></code> object which represents <var>registration</var>.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>
        Else: 
        <ol>
         <li>Let <var>worker</var> be a new <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-94">service worker</a>.
         <li>Generate a unique opaque string and set <var>worker</var>’s <a href="#dfn-service-worker-id" id="ref-for-dfn-service-worker-id-1">id</a> to the value.
         <li>Set <var>worker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-6">script url</a> to <var>job</var>’s <a href="#dfn-job-script-url" id="ref-for-dfn-job-script-url-12">script url</a>, <var>worker</var>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-6">script resource</a> to <var>script</var>, and <var>worker</var>’s <a href="#dfn-type" id="ref-for-dfn-type-2">type</a> to <var>job</var>’s <a data-link-type="dfn" href="#dfn-job-worker-type" id="ref-for-dfn-job-worker-type-3">worker type</a>.
         <li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>worker</var> as the argument.
         <li>
          If an uncaught runtime script error occurs during the above step, then: 
          <ol>
           <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a <code>TypeError</code>.
           <li>If <var>newestWorker</var> is null, invoke <a href="#clear-registration-algorithm">Clear Registration</a> algorithm passing <var>registration</var> as its argument.
           <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
          </ol>
        </ol>
       <li>Invoke <a href="#installation-algorithm">Install</a> algorithm with <var>job</var>, <var>worker</var>, and <var>registration</var> as its arguments.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="soft-update-algorithm">
      <h3 class="heading settled" id="soft-update-algorithm"><span class="content">Soft Update</span><a class="self-link" href="#soft-update-algorithm"></a></h3>
      <p>The user agent <em class="rfc2119" title="MAY">may</em> call this as often as it likes to check for updates.</p>
      <dl>
       <dt>Input
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-51">service worker registration</a>
       <dd><em>force bypass cache flag</em>, an optional flag unset by default
       <p class="note" role="note">Implementers may use the <em>force bypass cache flag</em> to aid debugging (e.g. invocations from developer tools), and other specifications that extend service workers may also use the flag on their own needs.</p>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>Let <var>newestWorker</var> be the result of running <a href="#get-newest-worker-algorithm">Get Newest Worker</a> algorithm passing <var>registration</var> as its argument.
       <li>If <var>newestWorker</var> is null, abort these steps.
       <li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>update</em>, <var>registration</var>’s <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-14">scope url</a>, <var>newestWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-7">script url</a>, null, and null.
       <li>Set <var>job</var>’s <a data-link-type="dfn" href="#dfn-job-worker-type" id="ref-for-dfn-job-worker-type-4">worker type</a> to <var>newestWorker</var>’s <a data-link-type="dfn" href="#dfn-type" id="ref-for-dfn-type-3">type</a>.
       <li>Set <var>job</var>’s <a href="#dfn-job-force-bypass-cache-flag" id="ref-for-dfn-job-force-bypass-cache-flag-1">force bypass cache flag</a> if its <em>force bypass cache flag</em> is set.
       <li>Invoke <a href="#schedule-job-algorithm">Schedule Job</a> with <var>job</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="installation-algorithm">
      <h3 class="heading settled" id="installation-algorithm"><span class="content">Install</span><a class="self-link" href="#installation-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-24">job</a>
       <dd><var>worker</var>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-95">service worker</a>
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-52">service worker registration</a>
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li>Let <var>installFailed</var> be false.
       <li>Let <var>newestWorker</var> be the result of running <a href="#get-newest-worker-algorithm">Get Newest Worker</a> algorithm passing <var>registration</var> as its argument.
       <li>Let <var>redundantWorker</var> be null.
       <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>installing</code>" and <var>worker</var> as the arguments.
       <li>Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-7">installing worker</a> and <em>installing</em> as the arguments.
       <li><a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: <var>job</var>’s <a href="#dfn-job-promise" id="ref-for-dfn-job-promise-7">promise</a> is not null.
       <li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-19">ServiceWorkerRegistration</a></code> object which represents <var>registration</var>.
       <li><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code>updatefound</code> at all the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-20">ServiceWorkerRegistration</a></code> objects for all the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-36">service worker clients</a> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a> <a href="#scope-match-algorithm">matches</a> <var>registration</var>’s <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-15">scope url</a> and all the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-96">service workers</a> whose <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-11">containing service worker registration</a> is <var>registration</var>.
       <li>Let <var>installingWorker</var> be <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-8">installing worker</a>.
       <li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>installingWorker</var> as the argument.
       <li>
        <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps: 
        <ol>
         <li>Create a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#concept-events-trusted">trusted event</a> <var>e</var> that uses the <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-14">ExtendableEvent</a></code> interface, with the event type <code><a href="#service-worker-global-scope-install-event" id="ref-for-service-worker-global-scope-install-event-6">install</a></code>, which does not bubble and is not cancelable.
         <li><a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">Dispatch</a> <var>e</var> at <var>installingWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> <var>globalObject</var>.
         <li>
          <em>WaitForAsynchronousExtensions</em>: Run the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
          <ol>
           <li>Wait until <var>e</var>’s <a data-link-type="dfn" href="#extensions-allowed-flag" id="ref-for-extensions-allowed-flag-5">extensions allowed flag</a> is unset.
           <li>If the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#waiting-for-all">waiting for all</a> of <var>e</var>’s <a data-link-type="dfn" href="#dfn-extend-lifetime-promises" id="ref-for-dfn-extend-lifetime-promises-12">extend lifetime promises</a> rejected, set <var>installFailed</var> to true.
          </ol>
        </ol>
       <p>If <var>task</var> is discarded or the script has been aborted by the <a href="#terminate-service-worker-algorithm">termination</a> of <var>installingWorker</var>, set <var>installFailed</var> to true.</p>
       <li>Wait for <var>task</var> to have executed or been discarded.
       <li>Wait for the step labeled <em>WaitForAsynchronousExtensions</em> to complete.
       <li>
        If <var>installFailed</var> is true, then: 
        <ol>
         <li>Set <var>redundantWorker</var> to <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-9">installing worker</a>.
         <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>installing</code>" and null as the arguments.
         <li>Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>redundantWorker</var> and <em>redundant</em> as the arguments.
         <li>If <var>newestWorker</var> is null, invoke <a href="#clear-registration-algorithm">Clear Registration</a> algorithm passing <var>registration</var> as its argument.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>Set <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-10">installing worker</a>’s <a href="#dfn-imported-scripts-updated-flag" id="ref-for-dfn-imported-scripts-updated-flag-2">imported scripts updated flag</a>.
       <li>
        If <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-6">waiting worker</a> is not null, then: 
        <ol>
         <li>Set <var>redundantWorker</var> to <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-7">waiting worker</a>.
         <li><a href="#terminate-service-worker-algorithm">Terminate</a> <var>redundantWorker</var>.
         <li>The user agent <em class="rfc2119" title="MAY">may</em> abort in-flight requests triggered by <var>redundantWorker</var>.
        </ol>
       <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>waiting</code>" and <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-11">installing worker</a> as the arguments.
       <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>installing</code>" and null as the arguments.
       <li>Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-8">waiting worker</a> and <em>installed</em> as the arguments.
       <li>If <var>redundantWorker</var> is not null, run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>redundantWorker</var> and <em>redundant</em> as the arguments.
       <li>
        If <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-9">waiting worker</a>’s <a href="#dfn-skip-waiting-flag" id="ref-for-dfn-skip-waiting-flag-3">skip waiting flag</a> is set, then: 
        <ol>
         <li>Run <a href="#activation-algorithm">Activate</a> algorithm passing <var>registration</var> as the argument.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var>.
       <li>Wait for all the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queued</a> by <a href="#update-state-algorithm">Update Worker State</a> invoked in this algorithm have executed.
       <li>Wait until no <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-37">service worker client</a> is <a href="#dfn-use" id="ref-for-dfn-use-4">using</a> <var>registration</var> or <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-10">waiting worker</a>’s <a href="#dfn-skip-waiting-flag" id="ref-for-dfn-skip-waiting-flag-4">skip waiting flag</a> is set.
       <li>If <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-11">waiting worker</a> <var>waitingWorker</var> is not null and <var>waitingWorker</var>’s <a href="#dfn-skip-waiting-flag" id="ref-for-dfn-skip-waiting-flag-5">skip waiting flag</a> is not set, invoke <a href="#activation-algorithm">Activate</a> algorithm with <var>registration</var> as its argument.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="activation-algorithm">
      <h3 class="heading settled" id="activation-algorithm"><span class="content">Activate</span><a class="self-link" href="#activation-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-53">service worker registration</a>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>If <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-12">waiting worker</a> is null, abort these steps.
       <li>Let <var>redundantWorker</var> be null.
       <li>
        If <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-22">active worker</a> is not null, then: 
        <ol>
         <li>Set <var>redundantWorker</var> to <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-23">active worker</a>.
         <li>Wait for <var>redundantWorker</var> to finish handling any in-progress requests. 
         <li><a href="#terminate-service-worker-algorithm">Terminate</a> <var>redundantWorker</var>.
        </ol>
       <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>active</code>" and <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-13">waiting worker</a> as the arguments.
       <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>waiting</code>" and null as the arguments.
       <li>
        Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-24">active worker</a> and <em>activating</em> as the arguments. 
        <p class="note" role="note">Once an active worker is activating, neither a runtime script error nor a force termination of the active worker prevents the active worker from getting activated.</p>
       <li>If <var>redundantWorker</var> is not null, run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>redundantWorker</var> and <em>redundant</em> as the arguments.
       <li>
        For each <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-38">service worker client</a> <var>client</var> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a> <a href="#scope-match-algorithm">matches</a> <var>registration</var>’s <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-16">scope url</a>: 
        <ol>
         <li>If <var>client</var> is a <a href="#dfn-window-client" id="ref-for-dfn-window-client-8">window client</a>, unassociate <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document">responsible document</a> from its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#application-cache">application cache</a>, if it has one.
         <li>Else if <var>client</var> is a <a href="#dfn-sharedworker-client" id="ref-for-dfn-sharedworker-client-3">shared worker client</a>, unassociate <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> from its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#application-cache">application cache</a>, if it has one.
        </ol>
        <p class="note" role="note">Resources will now use the service worker registration instead of the existing application cache.</p>
       <li>
        For each <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-39">service worker client</a> <var>client</var> who is <a href="#dfn-use" id="ref-for-dfn-use-5">using</a> <var>registration</var>: 
        <ol>
         <li>Set <var>client</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-25">active worker</a> to <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-26">active worker</a>.
         <li>Invoke <a href="#notify-controller-change-algorithm">Notify Controller Change</a> algorithm with <var>client</var> as the argument.
        </ol>
       <li>Let <var>activeWorker</var> be <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-27">active worker</a>.
       <li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the argument.
       <li>
        <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps: 
        <ol>
         <li>Create a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#concept-events-trusted">trusted event</a> <var>e</var> that uses the <code class="idl"><a data-link-type="idl" href="#extendable-event-interface" id="ref-for-extendable-event-interface-15">ExtendableEvent</a></code> interface, with the event type <code><a href="#service-worker-global-scope-activate-event" id="ref-for-service-worker-global-scope-activate-event-6">activate</a></code>, which does not bubble and is not cancelable.
         <li><a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">Dispatch</a> <var>e</var> at <var>activeWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>.
         <li><em>WaitForAsynchronousExtensions</em>: Wait, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>, until <var>e</var>’s <a data-link-type="dfn" href="#extensions-allowed-flag" id="ref-for-extensions-allowed-flag-6">extensions allowed flag</a> is unset.
        </ol>
       <li>Wait for <var>task</var> to have executed or been discarded, or the script to have been aborted by the <a href="#terminate-service-worker-algorithm">termination</a> of <var>activeWorker</var>.
       <li>Wait for the step labeled <em>WaitForAsynchronousExtensions</em> to complete.
       <li>Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-28">active worker</a> and <em>activated</em> as the arguments.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="run-service-worker-algorithm">
      <h3 class="heading settled" id="run-service-worker-algorithm"><span class="content">Run Service Worker</span><a class="self-link" href="#run-service-worker-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>serviceWorker</var>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-97">service worker</a>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>Let <var>script</var> be <var>serviceWorker</var>’s <a data-link-type="dfn" href="#dfn-script-resource" id="ref-for-dfn-script-resource-7">script resource</a>.
       <li>Assert: <var>script</var> is not null.
       <li>If <var>serviceWorker</var> is already running, abort these steps.
       <li>Create a separate parallel execution environment (i.e. a separate thread or process or equivalent construct), and run the rest of these steps in that context.
       <li>
        Call the JavaScript <a href="https://tc39.github.io/ecma262/#sec-initializehostdefinedrealm">InitializeHostDefinedRealm()</a> abstract operation with the following customizations: 
        <ul>
         <li>For the global object, create a new <code class="idl"><a data-link-type="idl" href="#service-worker-global-scope-interface" id="ref-for-service-worker-global-scope-interface-16">ServiceWorkerGlobalScope</a></code> object. Let <var>workerGlobalScope</var> be the created object.
         <li>Let <var>realmExecutionContext</var> be the created <a href="https://tc39.github.io/ecma262/#sec-execution-contexts">JavaScript execution context</a>.
        </ul>
       <li>Let <var>workerEventLoop</var> be a newly created <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a>.
       <li>Let <var>workerGlobalScope</var> be <var>realmExecutionContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-realm-global">global object</a>.
       <li>
        Let <var>settingsObject</var> be a new <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a> whose algorithms are defined as follows: 
        <dl>
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#realm-execution-context">realm execution context</a>
         <dd>Return <var>realmExecutionContext</var>.
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>
         <dd>Return <var>workerGlobalScope</var>.
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a>
         <dd>Return <var>workerEventLoop</var>.
         <dt>The <a data-link-type="dfn">referrer source</a>
         <dd>Return <var>serviceWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-8">script url</a>.
         <p class="issue" id="issue-b739bfcf"><a class="self-link" href="#issue-b739bfcf"></a>Remove this definition after sorting out the referencing sites.</p>
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#api-url-character-encoding">API URL character encoding</a>
         <dd>Return UTF-8.
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url">API base URL</a>
         <dd>Return <var>serviceWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-9">script url</a>.
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>
         <dd>Return its registering <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-40">service worker client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>.
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation URL</a>
         <dd>Return <var>workerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-url">url</a>.
         <dt>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#https-state">HTTPS state</a>
         <dd>Return <var>workerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-https-state">HTTPS state</a>.
        </dl>
       <li>Set <var>workerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-url">url</a> to <var>serviceWorker</var>’s <a href="#dfn-script-url" id="ref-for-dfn-script-url-10">script url</a>.
       <li>Set <var>workerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-https-state">HTTPS state</a> to <var>serviceWorker</var>’s <a data-link-type="dfn" href="#dfn-script-resource" id="ref-for-dfn-script-resource-8">script resource</a>’s <a href="#dfn-https-state" id="ref-for-dfn-https-state-1">HTTPS state</a>.
       <li>Set <var>workerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-type">type</a> to <var>serviceWorker</var>’s <a href="#dfn-type" id="ref-for-dfn-type-4">type</a>.
       <li>Create a new <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/workers.html#workerlocation">WorkerLocation</a></code> object and associate it with <var>workerGlobalScope</var>.
       <li>If <var>serviceWorker</var> is an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-29">active worker</a>, and there are any <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a> queued in <var>serviceWorker</var>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-12">containing service worker registration</a>’s <a href="#dfn-service-worker-registration-task-queue" id="ref-for-dfn-service-worker-registration-task-queue-3">task queues</a>, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue</a> them to <var>serviceWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queues</a> in the same order using their original <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task sources</a>.
       <li>
        If <var>script</var> is a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#classic-script">classic script</a>, then <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script">run the classic script</a> <var>script</var>. Otherwise, it is a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#module-script">module script</a>; <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#run-a-module-script">run the module script</a> <var>script</var>. 
        <p class="note" role="note">In addition to the usual possibilities of returning a value or failing due to an exception, this could be prematurely aborted by the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#kill-a-worker">kill a worker</a> or <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#terminate-a-worker">terminate a worker</a> algorithms.</p>
       <li>
        If <var>script</var>’s <a href="#dfn-has-ever-been-evaluated-flag" id="ref-for-dfn-has-ever-been-evaluated-flag-1">has ever been evaluated flag</a> is unset, then: 
        <ol>
         <li>
          Set <var>workerGlobalScope</var>’s associated <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-20">service worker</a>’s <a href="#dfn-set-of-event-types-to-handle" id="ref-for-dfn-set-of-event-types-to-handle-1">set of event types to handle</a> to the set of event types created from <var>settingsObject</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s associated list of <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-listener">event listeners</a>' event types. 
          <p class="note" role="note">If the global object’s associated list of event listeners does not have any event listener added at this moment, the service worker’s set of event types to handle is set to an empty set. The user agents are encouraged to show a warning that the event listeners must be added on the very first evaluation of the worker script.</p>
         <li>Set <var>script</var>’s <a href="#dfn-has-ever-been-evaluated-flag" id="ref-for-dfn-has-ever-been-evaluated-flag-2">has ever been evaluated flag</a>.
        </ol>
       <li>Run the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> specified by <var>settingsObject</var> until it is destroyed.
       <li>Empty <var>workerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#list-of-active-timers">list of active timers</a>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="terminate-service-worker-algorithm">
      <h3 class="heading settled" id="terminate-service-worker-algorithm"><span class="content">Terminate Service Worker</span><a class="self-link" href="#terminate-service-worker-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>serviceWorker</var>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-98">service worker</a>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>If <var>serviceWorker</var> is not running, abort these steps.
       <li>Let <var>serviceWorkerGlobalScope</var> be <var>serviceWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>.
       <li>Set <var>serviceWorkerGlobalScope</var>’s closing flag to true.
       <li>
        If there are any <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a>, whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a> is either the <a href="#dfn-handle-fetch-task-source" id="ref-for-dfn-handle-fetch-task-source-2">handle fetch task source</a> or the <a href="#dfn-handle-functional-event-task-source" id="ref-for-dfn-handle-functional-event-task-source-2">handle functional event task source</a>, queued in <var>serviceWorkerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queues</a>, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue</a> them to <var>serviceWorker</var>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-13">containing service worker registration</a>’s corresponding <a href="#dfn-service-worker-registration-task-queue" id="ref-for-dfn-service-worker-registration-task-queue-4">task queues</a> in the same order using their original <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task sources</a>, and discard all the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a> (including <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a> is neither the <a href="#dfn-handle-fetch-task-source" id="ref-for-dfn-handle-fetch-task-source-3">handle fetch task source</a> nor the <a href="#dfn-handle-functional-event-task-source" id="ref-for-dfn-handle-functional-event-task-source-3">handle functional event task source</a>) from <var>serviceWorkerGlobalScope</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queues</a> without processing them. 
        <p class="note" role="note">This effectively means that the fetch events and the other functional events such as push events are backed up by the registration’s task queues while the other tasks including message events are discarded.</p>
       <li>Abort the script currently running in <var>serviceWorker</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="on-fetch-request-algorithm">
      <h3 class="heading settled" id="on-fetch-request-algorithm"><span class="content">Handle Fetch</span><a class="self-link" href="#on-fetch-request-algorithm"></a></h3>
      <p>The <a href="#on-fetch-request-algorithm">Handle Fetch</a> algorithm is the entry point for the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> handling handed to the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-99">service worker</a> context.</p>
      <dl>
       <dt>Input
       <dd><var>request</var>, a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request">request</a>
       <dt>Output
       <dd><var>response</var>, a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response">response</a>
      </dl>
      <ol data-link-for-hint="FetchEvent">
       <li>Let <var>handleFetchFailed</var> be false.
       <li>Let <var>respondWithEntered</var> be false.
       <li>Let <var>eventCanceled</var> be false.
       <li>Let <var>r</var> be a new <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object associated with <var>request</var>.
       <li>Let <var>headersObject</var> be <var>r</var>’s <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#dom-request-headers">headers</a></code> attribute value.
       <li>Set <var>headersObject</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-headers-guard">guard</a> to <em>immutable</em>.
       <li>Let <var>response</var> be null.
       <li>Let <var>registration</var> be null.
       <li>Let <var>client</var> be the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-41">service worker client</a> that corresponds to <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-client">client</a>.
       <li>Assert: <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-destination">destination</a> is not "<code>serviceworker</code>".
       <li>
        If <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#potential-navigation-or-subresource-request">potential-navigation-or-subresource request</a>, then: 
        <ol>
         <li>Return null.
        </ol>
       <li>
        Else if <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</a>, then: 
        <p class="note" role="note">If the non-subresource request is under the scope of a service worker registration, application cache is completely bypassed regardless of whether the non-subresource request uses the service worker registration.</p>
        <ol>
         <li>If <var>client</var> is not a <a data-link-type="dfn" href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure context</a>, return null.
         <li>If <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#navigation-request">navigation request</a> and the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#navigate">navigation</a> triggering it was initiated with a shift+reload or equivalent, return null.
         <li>Set <var>registration</var> to the result of running <a href="#scope-match-algorithm">Match Service Worker Registration</a> algorithm passing <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a> as the argument.
         <li>If <var>registration</var> is null or <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-30">active worker</a> is null, return null.
         <li>Set <var>client</var>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-6">active worker</a> to <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-31">active worker</a>.
        </ol>
        <p class="note" role="note">From this point, the <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-42">service worker client</a> starts to <a href="#dfn-use" id="ref-for-dfn-use-6">use</a> its <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-7">active worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-14">containing service worker registration</a>.</p>
       <li>
        Else if <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#subresource-request">subresource request</a>, then: 
        <ol>
         <li>If <var>client</var>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-8">active worker</a> is non-null, set <var>registration</var> to <var>client</var>’s <a href="#dfn-service-worker-client-active-worker" id="ref-for-dfn-service-worker-client-active-worker-9">active worker</a>’s <a href="#dfn-containing-service-worker-registration" id="ref-for-dfn-containing-service-worker-registration-15">containing service worker registration</a>.
         <li>Else, return null.
        </ol>
       <li>Let <var>activeWorker</var> be <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-32">active worker</a>.
       <li>
        If <var>activeWorker</var>’s <a href="#dfn-set-of-event-types-to-handle" id="ref-for-dfn-set-of-event-types-to-handle-2">set of event types to handle</a> does not contain <code>fetch</code>, return null. 
        <p class="note" role="note">To avoid unnecessary delays, the Handle Fetch enforces early return when no event listeners have been deterministically added in the service worker’s global during the very first script execution.</p>
       <li>If <var>activeWorker</var>’s <a href="#dfn-state" id="ref-for-dfn-state-10">state</a> is <em>activating</em>, wait for <var>activeWorker</var>’s <a href="#dfn-state" id="ref-for-dfn-state-11">state</a> to become <em>activated</em>.
       <li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the argument.
       <li>
        <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps: 
        <ol>
         <li>Create a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#concept-events-trusted">trusted event</a> <var>e</var> that uses the <code class="idl"><a data-link-type="idl" href="#fetch-event-interface" id="ref-for-fetch-event-interface-5">FetchEvent</a></code> interface, with the event type <code><a href="#service-worker-global-scope-fetch-event" id="ref-for-service-worker-global-scope-fetch-event-7">fetch</a></code>, which does not bubble.
         <li>Let the <a href="#fetch-event-request-attribute" id="ref-for-fetch-event-request-attribute-3">request</a> attribute of <var>e</var> be initialized to <var>r</var>.
         <li>Let the <a href="#fetch-event-clientid-attribute" id="ref-for-fetch-event-clientid-attribute-3">clientId</a> attribute of <var>e</var> be initialized to <var>client</var>’s <a href="#dfn-service-worker-client-id" id="ref-for-dfn-service-worker-client-id-3">id</a> if <var>request</var> is not a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</a>, and to null otherwise.
         <li>Let the <a href="#fetch-event-isreload-attribute" id="ref-for-fetch-event-isreload-attribute-3">isReload</a> attribute of <var>e</var> be initialized to <code>true</code> if <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-client">client</a> is a <a href="#dfn-window-client" id="ref-for-dfn-window-client-9">window client</a> and the event was dispatched with the user’s intention for the page reload, and <code>false</code> otherwise.
         <li><a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-event-dispatch">Dispatch</a> <var>e</var> at <var>activeWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>.
         <li>If <var>e</var>’s <a href="#respond-with-entered-flag" id="ref-for-respond-with-entered-flag-3">respond-with entered flag</a> is set, set <var>respondWithEntered</var> to true.
         <li>
          If <var>e</var>’s <a href="#wait-to-respond-flag" id="ref-for-wait-to-respond-flag-3">wait to respond flag</a> is set, then: 
          <ol>
           <li>Wait until <var>e</var>’s <a href="#wait-to-respond-flag" id="ref-for-wait-to-respond-flag-4">wait to respond flag</a> is unset.
           <li>If <var>e</var>’s <a href="#respond-with-error-flag" id="ref-for-respond-with-error-flag-5">respond-with error flag</a> is set, set <var>handleFetchFailed</var> to true.
           <li>Else, set <var>response</var> to <var>e</var>’s <a data-link-type="dfn" href="#fetchevent-potential-response" id="ref-for-fetchevent-potential-response-2">potential response</a>.
          </ol>
         <li>If <var>e</var>’s <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#canceled-flag">canceled flag</a> is set, set <var>eventCanceled</var> to true.
        </ol>
        <p>If <var>task</var> is discarded or the script has been aborted by the <a href="#terminate-service-worker-algorithm">termination</a> of <var>activeWorker</var>, set <var>handleFetchFailed</var> to true.</p>
        <p>The <var>task</var> <em class="rfc2119" title="MUST">must</em> use <var>activeWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a> and the <a href="#dfn-handle-fetch-task-source" id="ref-for-dfn-handle-fetch-task-source-4">handle fetch task source</a>.</p>
       <li>Wait for <var>task</var> to have executed or been discarded.
       <li>
        If <var>respondWithEntered</var> is false, then: 
        <ol>
         <li>If <var>eventCanceled</var> is true, return a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a> and continue running these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>.
         <li>Else, return null and continue running these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>.
         <li>If <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</a>, or <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#subresource-request">subresource request</a> and the time difference in seconds calculated by the current time minus <var>registration</var>’s <a href="#dfn-last-update-check-time" id="ref-for-dfn-last-update-check-time-4">last update check time</a> is greater than 86400, invoke <a href="#soft-update-algorithm">Soft Update</a> algorithm with <var>registration</var>.
         <li>Abort these steps.
        </ol>
       <li>
        If <var>handleFetchFailed</var> is true, then: 
        <ol>
         <li>Return a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a> and continue running these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>.
         <li>If <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</a>, or <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#subresource-request">subresource request</a> and the time difference in seconds calculated by the current time minus <var>registration</var>’s <a href="#dfn-last-update-check-time" id="ref-for-dfn-last-update-check-time-5">last update check time</a> is greater than 86400, invoke <a href="#soft-update-algorithm">Soft Update</a> algorithm with <var>registration</var>.
        </ol>
       <li>
        Else: 
        <ol>
         <li>Return <var>response</var> and continue running these substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>.
         <li>If <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</a>, or <var>request</var> is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#subresource-request">subresource request</a> and the time difference in seconds calculated by the current time minus <var>registration</var>’s <a href="#dfn-last-update-check-time" id="ref-for-dfn-last-update-check-time-6">last update check time</a> is greater than 86400, invoke <a href="#soft-update-algorithm">Soft Update</a> algorithm with <var>registration</var>.
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="handle-functional-event-algorithm">
      <h3 class="heading settled" id="handle-functional-event-algorithm"><span class="content">Handle Functional Event</span><a class="self-link" href="#handle-functional-event-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-54">service worker registration</a>
       <dd><var>callbackSteps</var>, an algorithm
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li><a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> with the [[value]] equals to <var>registration</var> is contained in <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-7">scope to registration map</a>.
       <li><a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-33">active worker</a> is not null.
       <li>Let <var>activeWorker</var> be <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-34">active worker</a>.
       <li>
        If <var>activeWorker</var>’s <a href="#dfn-set-of-event-types-to-handle" id="ref-for-dfn-set-of-event-types-to-handle-3">set of event types to handle</a> does not contain the event type for this functional event, return. 
        <p class="note" role="note">To avoid unnecessary delays, the Handle Functional Event enforces early return when no event listeners have been deterministically added in the service worker’s global during the very first script execution.</p>
       <li>If <var>activeWorker</var>’s <a href="#dfn-state" id="ref-for-dfn-state-12">state</a> is <em>activating</em>, wait for <var>activeWorker</var>’s <a href="#dfn-state" id="ref-for-dfn-state-13">state</a> to become <em>activated</em>.
       <li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the argument.
       <li>
        <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to invoke <var>callbackSteps</var> with <var>activeWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a> as its argument. 
        <p>The <var>task</var> <em class="rfc2119" title="MUST">must</em> use <var>activeWorker</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loop</a> and the <a href="#dfn-handle-functional-event-task-source" id="ref-for-dfn-handle-functional-event-task-source-4">handle functional event task source</a>.</p>
       <li>Wait for <var>task</var> to have executed or been discarded.
       <li>If the time difference in seconds calculated by the current time minus <var>registration</var>’s <a href="#dfn-last-update-check-time" id="ref-for-dfn-last-update-check-time-7">last update check time</a> is greater than 86400, invoke <a href="#soft-update-algorithm">Soft Update</a> algorithm with <var>registration</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="on-client-unload-algorithm">
      <h3 class="heading settled" id="on-client-unload-algorithm"><span class="content">Handle Service Worker Client Unload</span><a class="self-link" href="#on-client-unload-algorithm"></a></h3>
      <p>The user agent <em class="rfc2119" title="MUST">must</em> run these steps when a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-43">service worker client</a> unloads by <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#unload-a-document">unloading</a>, <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/workers.html#kill-a-worker">being killed</a>, or <a href="#terminate-service-worker-algorithm">terminating</a>.</p>
      <dl>
       <dt>Input
       <dd><var>client</var>, a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-44">service worker client</a>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>Run the following steps atomically.
       <li>Let <var>registration</var> be the <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-55">service worker registration</a> <a href="#dfn-use" id="ref-for-dfn-use-7">used</a> by <var>client</var>.
       <li>If <var>registration</var> is null, abort these steps.
       <li>If any other <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-45">service worker client</a> is <a href="#dfn-use" id="ref-for-dfn-use-8">using</a> <var>registration</var>, abort these steps.
       <li>If <var>registration</var>’s <a href="#dfn-uninstalling-flag" id="ref-for-dfn-uninstalling-flag-4">uninstalling flag</a> is set, invoke <a href="#clear-registration-algorithm">Clear Registration</a> algorithm passing <var>registration</var> as its argument and abort these steps.
       <li>If <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-14">waiting worker</a> is not null, run <a href="#activation-algorithm">Activate</a> algorithm with <var>registration</var> as the argument.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="on-user-agent-shutdown-algorithm">
      <h3 class="heading settled" id="on-user-agent-shutdown-algorithm"><span class="content">Handle User Agent Shutdown</span><a class="self-link" href="#on-user-agent-shutdown-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd>None
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>
        For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of its <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-8">scope to registration map</a>: 
        <ol>
         <li>Let <var>registration</var> be <var>entry</var>.[[value]].
         <li>
          If <var>registration</var>’s <a data-link-type="dfn" href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-12">installing worker</a> <var>installingWorker</var> is not null, then: 
          <ol>
           <li>If the result of running <a href="#get-newest-worker-algorithm">Get Newest Worker</a> with <var>registration</var> is <var>installingWorker</var>, invoke <a href="#clear-registration-algorithm">Clear Registration</a> with <var>registration</var> and continue to the next iteration of the loop.
           <li>Else, set <var>registration</var>’s <a data-link-type="dfn" href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-13">installing worker</a> to null.
          </ol>
         <li>
          If <var>registration</var>’s <a data-link-type="dfn" href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-15">waiting worker</a> is not null, run the following substep <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
          <ol>
           <li>Invoke <a href="#activation-algorithm">Activate</a> with <var>registration</var>.
          </ol>
        </ol>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="unregister-algorithm">
      <h3 class="heading settled" id="unregister-algorithm"><span class="content">Unregister</span><a class="self-link" href="#unregister-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>job</var>, a <a href="#dfn-job" id="ref-for-dfn-job-25">job</a>
       <dt>Output
       <dd>none
      </dl>
      <ol>
       <li>
        If the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> of <var>job</var>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-9">scope url</a> is not <var>job</var>’s <a href="#dfn-job-client" id="ref-for-dfn-job-client-14">client</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>, then: 
        <ol>
         <li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>Let <var>registration</var> be the result of running <a href="#get-registration-algorithm">Get Registration</a> algorithm passing <var>job</var>’s <a href="#dfn-job-scope-url" id="ref-for-dfn-job-scope-url-10">scope url</a> as the argument.
       <li>
        If <var>registration</var> is null, then: 
        <ol>
         <li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and false.
         <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.
        </ol>
       <li>Set <var>registration</var>’s <a href="#dfn-uninstalling-flag" id="ref-for-dfn-uninstalling-flag-5">uninstalling flag</a>.
       <li>Invoke <a href="#resolve-job-promise-algorithm">Resolve Job Promise</a> with <var>job</var> and true.
       <li>
        If no <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-46">service worker client</a> is <a href="#dfn-use" id="ref-for-dfn-use-9">using</a> <var>registration</var>, invoke <a href="#clear-registration-algorithm">Clear Registration</a> algorithm passing <var>registration</var> as its argument. 
        <p class="note" role="note">When the registration is being used for a client, the deletion of the registration is handled by the Handle Service Worker Client Unload algorithm.</p>
       <li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="set-registration-algorithm">
      <h3 class="heading settled" id="set-registration-algorithm"><span class="content">Set Registration</span><a class="self-link" href="#set-registration-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>scope</var>, a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>
       <dt>Output
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-56">service worker registration</a>
      </dl>
      <ol>
       <li>Run the following steps atomically.
       <li>Let <var>scopeString</var> be <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <var>scope</var> with the <em>exclude fragment flag</em> set.
       <li>Let <var>registration</var> be a new <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-57">service worker registration</a> whose <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-17">scope url</a> is set to <var>scope</var>.
       <li>Set a newly-created <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]]: <var>scopeString</var>, [[value]]: <var>registration</var>} to <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-9">scope to registration map</a>.
       <li>Return <var>registration</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="clear-registration-algorithm">
      <h3 class="heading settled" id="clear-registration-algorithm"><span class="content">Clear Registration</span><a class="self-link" href="#clear-registration-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-58">service worker registration</a>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>Run the following steps atomically.
       <li>Let <var>redundantWorker</var> be null.
       <li>
        If <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-14">installing worker</a> is not null, then: 
        <ol>
         <li>Set <var>redundantWorker</var> to <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-15">installing worker</a>.
         <li><a href="#terminate-service-worker-algorithm">Terminate</a> <var>redundantWorker</var>.
         <li>The user agent <em class="rfc2119" title="MAY">may</em> abort in-flight requests triggered by <var>redundantWorker</var>.
         <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>installing</code>" and null as the arguments.
         <li>Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>redundantWorker</var> and <em>redundant</em> as the arguments.
        </ol>
       <li>
        If <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-16">waiting worker</a> is not null, then: 
        <ol>
         <li>Set <var>redundantWorker</var> to <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-17">waiting worker</a>.
         <li><a href="#terminate-service-worker-algorithm">Terminate</a> <var>redundantWorker</var>.
         <li>The user agent <em class="rfc2119" title="MAY">may</em> abort in-flight requests triggered by <var>redundantWorker</var>.
         <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>waiting</code>" and null as the arguments.
         <li>Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>redundantWorker</var> and <em>redundant</em> as the arguments.
        </ol>
       <li>
        If <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-35">active worker</a> is not null, then: 
        <ol>
         <li>Set <var>redundantWorker</var> to <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-36">active worker</a>.
         <li><a href="#terminate-service-worker-algorithm">Terminate</a> <var>redundantWorker</var>.
         <li>The user agent <em class="rfc2119" title="MAY">may</em> abort in-flight requests triggered by <var>redundantWorker</var>.
         <li>Run the <a href="#update-registration-state-algorithm">Update Registration State</a> algorithm passing <var>registration</var>, "<code>active</code>" and null as the arguments.
         <li>Run the <a href="#update-state-algorithm">Update Worker State</a> algorithm passing <var>redundantWorker</var> and <em>redundant</em> as the arguments.
        </ol>
       <li>Delete a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> from <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-10">scope to registration map</a> where <var>registration</var>’s <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-18">scope url</a> is the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>entry</var>.[[key]].
      </ol>
     </section>
     <section class="algorithm" data-algorithm="update-registration-state-algorithm">
      <h3 class="heading settled" id="update-registration-state-algorithm"><span class="content">Update Registration State</span><a class="self-link" href="#update-registration-state-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-59">service worker registration</a>
       <dd><var>target</var>, a string (one of "<code>installing</code>", "<code>waiting</code>", and "<code>active</code>")
       <dd><var>source</var>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-100">service worker</a> or null
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>Let <var>registrationObjects</var> be an array containing all the <code class="idl"><a data-link-type="idl" href="#service-worker-registration-interface" id="ref-for-service-worker-registration-interface-21">ServiceWorkerRegistration</a></code> objects associated with <var>registration</var>.
       <li>
        If <var>target</var> is "<code>installing</code>", then: 
        <ol>
         <li>Set <var>registration</var>’s <a data-link-type="dfn" href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-16">installing worker</a> to <var>source</var>.
         <li>
          For each <var>registrationObject</var> in <var>registrationObjects</var>: 
          <ol>
           <li><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to set the <a href="#service-worker-registration-installing-attribute" id="ref-for-service-worker-registration-installing-attribute-3">installing</a> attribute of <var>registrationObject</var> to the <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-29">ServiceWorker</a></code> object that represents <var>registration</var>’s <a data-link-type="dfn" href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-17">installing worker</a>, or null if <var>registration</var>’s <a data-link-type="dfn" href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-18">installing worker</a> is null.
          </ol>
        </ol>
       <li>
        Else if <var>target</var> is "<code>waiting</code>", then: 
        <ol>
         <li>Set <var>registration</var>’s <a data-link-type="dfn" href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-18">waiting worker</a> to <var>source</var>.
         <li>
          For each <var>registrationObject</var> in <var>registrationObjects</var>: 
          <ol>
           <li><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to set the <a href="#service-worker-registration-waiting-attribute" id="ref-for-service-worker-registration-waiting-attribute-3">waiting</a> attribute of <var>registrationObject</var> to the <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-30">ServiceWorker</a></code> object that represents <var>registration</var>’s <a data-link-type="dfn" href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-19">waiting worker</a>, or null if <var>registration</var>’s <a data-link-type="dfn" href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-20">waiting worker</a> is null.
          </ol>
        </ol>
       <li>
        Else if <var>target</var> is "<code>active</code>", then: 
        <ol>
         <li>Set <var>registration</var>’s <a data-link-type="dfn" href="#dfn-active-worker" id="ref-for-dfn-active-worker-37">active worker</a> to <var>source</var>.
         <li>
          For each <var>registrationObject</var> in <var>registrationObjects</var>: 
          <ol>
           <li><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to set the <a href="#service-worker-registration-active-attribute" id="ref-for-service-worker-registration-active-attribute-3">active</a> attribute of <var>registrationObject</var> to the <code class="idl"><a data-link-type="idl" href="#service-worker-interface" id="ref-for-service-worker-interface-31">ServiceWorker</a></code> object that represents <var>registration</var>’s <a data-link-type="dfn" href="#dfn-active-worker" id="ref-for-dfn-active-worker-38">active worker</a>, or null if <var>registration</var>’s <a data-link-type="dfn" href="#dfn-active-worker" id="ref-for-dfn-active-worker-39">active worker</a> is null.
          </ol>
        </ol>
        <p>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">task</a> <em class="rfc2119" title="MUST">must</em> use <var>registrationObject</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> and the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="update-state-algorithm">
      <h3 class="heading settled" id="update-state-algorithm"><span class="content">Update Worker State</span><a class="self-link" href="#update-state-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>worker</var>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-101">service worker</a>
       <dd><var>state</var>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-102">service worker</a>’s <a href="#dfn-state" id="ref-for-dfn-state-14">state</a>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li>Set <var>worker</var>’s <a href="#dfn-state" id="ref-for-dfn-state-15">state</a> to <var>state</var>.
       <li>Let <var>workerObjects</var> be an array containing all the <code><a href="#service-worker-interface" id="ref-for-service-worker-interface-32">ServiceWorker</a></code> objects associated with <var>worker</var>.
       <li>
        For each <var>workerObject</var> in <var>workerObjects</var>: 
        <ol>
         <li>
          <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to run these substeps: 
          <ol>
           <li>
            Set the <a href="#service-worker-state-attribute" id="ref-for-service-worker-state-attribute-5">state</a> attribute of <var>workerObject</var> to the value (in <code class="idl"><a data-link-type="idl" href="#service-worker-state-enum" id="ref-for-service-worker-state-enum-4">ServiceWorkerState</a></code> enumeration) corresponding to the first matching statement, switching on <var>worker</var>’s <a href="#dfn-state" id="ref-for-dfn-state-16">state</a>: 
            <dl>
             <dt><em>installing</em>
             <dd>
              "<code>installing</code>" 
              <p class="note" role="note">The <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-103">service worker</a> in this state is considered an <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-19">installing worker</a>. During this state, <code><a href="#extendable-event-waituntil-method" id="ref-for-extendable-event-waituntil-method-6">event.waitUntil(<var>f</var>)</a></code> can be called inside the <code><a href="#service-worker-global-scope-oninstall-attribute" id="ref-for-service-worker-global-scope-oninstall-attribute-2">oninstall</a></code> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a> to extend the life of the <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-20">installing worker</a> until the passed <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolves successfully. This is primarily used to ensure that the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-104">service worker</a> is not active until all of the core caches are populated.</p>
             <dt><em>installed</em>
             <dd>
              "<code>installed</code>" 
              <p class="note" role="note">The <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-105">service worker</a> in this state is considered a <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-21">waiting worker</a>.</p>
             <dt><em>activating</em>
             <dd>
              "<code>activating</code>" 
              <p class="note" role="note">The <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-106">service worker</a> in this state is considered an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-40">active worker</a>. During this state, <code><a href="#extendable-event-waituntil-method" id="ref-for-extendable-event-waituntil-method-7">event.waitUntil(<var>f</var>)</a></code> can be called inside the <code><a href="#service-worker-global-scope-onactivate-attribute" id="ref-for-service-worker-global-scope-onactivate-attribute-2">onactivate</a></code> <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handler</a> to extend the life of the <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-41">active worker</a> until the passed <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolves successfully. No <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-10">functional events</a> are dispatched until the state becomes <em>activated</em>.</p>
             <dt><em>activated</em>
             <dd>
              "<code>activated</code>" 
              <p class="note" role="note">The <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-107">service worker</a> in this state is considered an <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-42">active worker</a> ready to handle <a href="#dfn-functional-events" id="ref-for-dfn-functional-events-11">functional events</a>.</p>
             <dt><em>redundant</em>
             <dd>
              "<code>redundant</code>" 
              <p class="note" role="note">A new <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-108">service worker</a> is replacing the current <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-109">service worker</a>, or the current <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-110">service worker</a> is being discarded due to an install failure.</p>
            </dl>
           <li><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-simple-event">Fire a simple event</a> named <code>statechange</code> at <var>workerObject</var>.
          </ol>
        </ol>
        <p>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">task</a> <em class="rfc2119" title="MUST">must</em> use <var>workerObject</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> and the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
      </ol>
     </section>
     <section class="algorithm" data-algorithm="notify-controller-change-algorithm">
      <h3 class="heading settled" id="notify-controller-change-algorithm"><span class="content">Notify Controller Change</span><a class="self-link" href="#notify-controller-change-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>client</var>, a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-47">service worker client</a>
       <dt>Output
       <dd>None
      </dl>
      <ol>
       <li><a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: <var>client</var> is not null.
       <li><a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> to <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code>controllerchange</code> at the <code><a href="#service-worker-container-interface" id="ref-for-service-worker-container-interface-16">ServiceWorkerContainer</a></code> object <var>client</var> is <a href="#dfn-service-worker-container-interface-client" id="ref-for-dfn-service-worker-container-interface-client-8">associated</a> with.
      </ol>
      <p>The <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">task</a> <em class="rfc2119" title="MUST">must</em> use <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> and the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
     </section>
     <section class="algorithm" data-algorithm="scope-match-algorithm">
      <h3 class="heading settled" id="scope-match-algorithm"><span class="content">Match Service Worker Registration</span><a class="self-link" href="#scope-match-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>clientURL</var>, a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>
       <dt>Output
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-60">service worker registration</a>
      </dl>
      <ol>
       <li>Run the following steps atomically.
       <li>Let <var>clientURLString</var> be <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <var>clientURL</var>.
       <li>Let <var>matchingScope</var> be the empty string.
       <li>
        Set <var>matchingScope</var> to the longest [[key]] in <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-11">scope to registration map</a> which the value of <var>clientURLString</var> starts with, if it exists. 
        <p class="note" role="note">The URL string matching in this step is prefix-based rather than path-structural (e.g. a client URL string with "/prefix-of/resource.html" will match a registration for a scope with "/prefix").</p>
       <li>Let <var>parsedMatchingScope</var> be null.
       <li>If <var>matchingScope</var> is not the empty string, set <var>parsedMatchingScope</var> to the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>matchingScope</var>.
       <li>Let <var>registration</var> be the result of running <a href="#get-registration-algorithm">Get Registration</a> algorithm passing <var>parsedMatchingScope</var> as the argument.
       <li>If <var>registration</var> is not null and <var>registration</var>’s <a href="#dfn-uninstalling-flag" id="ref-for-dfn-uninstalling-flag-6">uninstalling flag</a> is set, return null.
       <li>Return <var>registration</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="get-registration-algorithm">
      <h3 class="heading settled" id="get-registration-algorithm"><span class="content">Get Registration</span><a class="self-link" href="#get-registration-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>scope</var>, a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL</a>
       <dt>Output
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-61">service worker registration</a>
      </dl>
      <ol>
       <li>Run the following steps atomically.
       <li>Let <var>scopeString</var> be the empty string.
       <li>If <var>scope</var> is not null, set <var>scopeString</var> to <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <var>scope</var> with the <em>exclude fragment flag</em> set.
       <li>Let <var>registration</var> be null.
       <li>
        For each <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} <var>entry</var> of its <a href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-12">scope to registration map</a>: 
        <ol>
         <li>If <var>scopeString</var> matches <var>entry</var>.[[key]], set <var>registration</var> to <var>entry</var>.[[value]].
        </ol>
       <li>Return <var>registration</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="get-newest-worker-algorithm">
      <h3 class="heading settled" id="get-newest-worker-algorithm"><span class="content">Get Newest Worker</span><a class="self-link" href="#get-newest-worker-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>registration</var>, a <a href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-62">service worker registration</a>
       <dt>Output
       <dd><var>worker</var>, a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-111">service worker</a>
      </dl>
      <ol>
       <li>Run the following steps atomically.
       <li>Let <var>newestWorker</var> be null.
       <li>If <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-21">installing worker</a> is not null, set <var>newestWorker</var> to <var>registration</var>’s <a href="#dfn-installing-worker" id="ref-for-dfn-installing-worker-22">installing worker</a>.
       <li>Else if <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-22">waiting worker</a> is not null, set <var>newestWorker</var> to <var>registration</var>’s <a href="#dfn-waiting-worker" id="ref-for-dfn-waiting-worker-23">waiting worker</a>.
       <li>Else if <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-43">active worker</a> is not null, set <var>newestWorker</var> to <var>registration</var>’s <a href="#dfn-active-worker" id="ref-for-dfn-active-worker-44">active worker</a>.
       <li>Return <var>newestWorker</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="create-client-algorithm">
      <h3 class="heading settled" id="create-client-algorithm"><span class="content">Create Client</span><a class="self-link" href="#create-client-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>client</var>, a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-48">service worker client</a>
       <dt>Output
       <dd><var>clientObject</var>, a <code class="idl"><a data-link-type="idl" href="#client-interface" id="ref-for-client-interface-9">Client</a></code> object
      </dl>
      <ol>
       <li>Let <var>clientObject</var> be a new <code class="idl"><a data-link-type="idl" href="#client-interface" id="ref-for-client-interface-10">Client</a></code> object.
       <li>Set <var>clientObject</var>’s <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-11">service worker client</a> to <var>client</var>.
       <li>Return <var>clientObject</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="create-windowclient-algorithm">
      <h3 class="heading settled" id="create-windowclient-algorithm"><span class="content">Create Window Client</span><a class="self-link" href="#create-windowclient-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>client</var>, a <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-49">service worker client</a>
       <dd><var>visibilityState</var>, a string
       <dd><var>focusState</var>, a boolean
       <dt>Output
       <dd><var>windowClient</var>, a <code class="idl"><a data-link-type="idl" href="#window-client-interface" id="ref-for-window-client-interface-7">WindowClient</a></code> object
      </dl>
      <ol>
       <li>Let <var>windowClient</var> be a new <code class="idl"><a data-link-type="idl" href="#window-client-interface" id="ref-for-window-client-interface-8">WindowClient</a></code> object.
       <li>Set <var>windowClient</var>’s <a href="#dfn-service-worker-client-client" id="ref-for-dfn-service-worker-client-client-12">service worker client</a> to <var>client</var>.
       <li>Set <var>windowClient</var>’s <a href="#dfn-service-worker-client-visibilitystate" id="ref-for-dfn-service-worker-client-visibilitystate-2">visibility state</a> to <var>visibilityState</var>.
       <li>Set <var>windowClient</var>’s <a href="#dfn-service-worker-client-focusstate" id="ref-for-dfn-service-worker-client-focusstate-3">focus state</a> to <var>focusState</var>.
       <li>Return <var>windowClient</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="query-cache-algorithm">
      <h3 class="heading settled" id="query-cache-algorithm"><span class="content">Query Cache</span><a class="self-link" href="#query-cache-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>request</var>, a <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code> object
       <dd><var>options</var>, a <code class="idl"><a data-link-type="idl" href="#dictdef-cache-cachequeryoptions" id="ref-for-dictdef-cache-cachequeryoptions-7">CacheQueryOptions</a></code> object, optional
       <dd><var>targetStorage</var>, an array that has [<code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code>, <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code>] pairs as its elements, optional
       <dt>Output
       <dd><var>resultArray</var>, an array that has [<code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#request">Request</a></code>, <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code>] pairs as its elements
      </dl>
      <ol>
       <li>Let <var>requestArray</var> be an empty array.
       <li>Let <var>responseArray</var> be an empty array.
       <li>Let <var>resultArray</var> be an empty array.
       <li>If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachequeryoptions-ignoremethod" id="ref-for-dom-cachequeryoptions-ignoremethod-1">ignoreMethod</a></code> is false and <var>request</var>.<var>method</var> is not `<code>GET</code>`, return <var>resultArray</var>.
       <li>Let <var>cachedURL</var> and <var>requestURL</var> be null.
       <li>
        If the optional argument <var>targetStorage</var> is omitted, then: 
        <ol>
         <li>
          For each <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-11">fetching record</a> <var>entry</var> of its <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-17">request to response map</a>, in key insertion order: 
          <ol>
           <li>Set <var>cachedURL</var> to <var>entry</var>.[[key]]'s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>.
           <li>Set <var>requestURL</var> to <var>request</var>’s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>.
           <li>
            If <var>options</var>.<var>ignoreSearch</var> is true, then: 
            <ol>
             <li>Set <var>cachedURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> to the empty string.
             <li>Set <var>requestURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> to the empty string.
            </ol>
           <li>
            If <var>cachedURL</var> <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-equals">equals</a> <var>requestURL</var> with the <em>exclude fragments flag</em> set, then: 
            <ol>
             <li>Add a copy of <var>entry</var>.[[key]] to <var>requestArray</var>.
             <li>Add a copy of <var>entry</var>.[[value]] to <var>responseArray</var>.
            </ol>
          </ol>
        </ol>
       <li>
        Else: 
        <ol>
         <li>
          For each <var>record</var> in <var>targetStorage</var>: 
          <ol>
           <li>Set <var>cachedURL</var> to <var>record</var>[0]'s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>.
           <li>Set <var>requestURL</var> to <var>request</var>’s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>.
           <li>
            If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachequeryoptions-ignoresearch" id="ref-for-dom-cachequeryoptions-ignoresearch-1">ignoreSearch</a></code> is true, then: 
            <ol>
             <li>Set <var>cachedURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> to the empty string.
             <li>Set <var>requestURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> to the empty string.
            </ol>
           <li>
            If <var>cachedURL</var> <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-equals">equals</a> <var>requestURL</var> with the <em>exclude fragments flag</em> set, then: 
            <ol>
             <li>Add <var>record</var>[0] to <var>requestArray</var>.
             <li>Add <var>record</var>[1] to <var>responseArray</var>.
            </ol>
          </ol>
        </ol>
       <li>
        For each <var>cachedResponse</var> in <var>responseArray</var> with the index <var>index</var>: 
        <ol>
         <li>Let <var>cachedRequest</var> be the <var>index</var>th element in <var>requestArray</var>.
         <li>
          If <var>cachedResponse</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-response">response</a>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a> contains no <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header">header</a> <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header-name">named</a> `<code>Vary</code>`, or <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachequeryoptions-ignorevary" id="ref-for-dom-cachequeryoptions-ignorevary-1">ignoreVary</a></code> is true, then: 
          <ol>
           <li>Add an array [<var>cachedRequest</var>, <var>cachedResponse</var>] to <var>resultArray</var>.
           <li>Continue to the next iteration of the loop.
          </ol>
         <li>Let <var>varyHeaders</var> be the array containing the elements corresponding to the <a data-link-type="dfn" href="https://tools.ietf.org/html/rfc7230#section-3.2">field-values</a> of the <a data-link-type="dfn" href="https://tools.ietf.org/html/rfc7231#section-7.1.4">Vary</a> header.
         <li>Let <var>matchFailed</var> be false.
         <li>
          For each <var>f</var> in <var>varyHeaders</var>: 
          <ol>
           <li>
            If <var>f</var> matches "<code>*</code>", or the result of running <var>cachedRequest</var>.<code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#dom-request-headers">headers</a></code> object’s <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#dom-headers-get">get(name)</a></code> method with <var>f</var> as the argument does not match the result of running <var>request</var>.<code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#dom-request-headers">headers</a></code> object’s <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#dom-headers-get">get(name)</a></code> method with <var>f</var> as the argument, then: 
            <ol>
             <li>Set <var>matchFailed</var> to true.
             <li>Break the loop.
            </ol>
          </ol>
         <li>If <var>matchFailed</var> is false, add an array [<var>cachedRequest</var>, <var>cachedResponse</var>] to <var>resultArray</var>.
        </ol>
       <li>Return <var>resultArray</var>.
      </ol>
     </section>
     <section class="algorithm" data-algorithm="batch-cache-operations-algorithm">
      <h3 class="heading settled" id="batch-cache-operations-algorithm"><span class="content">Batch Cache Operations</span><a class="self-link" href="#batch-cache-operations-algorithm"></a></h3>
      <dl>
       <dt>Input
       <dd><var>operations</var>, an array of <code class="idl"><a data-link-type="idl" href="#dictdef-cache-cachebatchoperation" id="ref-for-dictdef-cache-cachebatchoperation-4">CacheBatchOperation</a></code> dictionary objects
       <dt>Output
       <dd><var>promise</var>, a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolves with an array of <code class="idl"><a data-link-type="idl" href="https://fetch.spec.whatwg.org/#response">Response</a></code> objects.
      </dl>
      <ol>
       <li>Let <var>p</var> be a <a data-link-type="dfn" href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a> resolved with no value.
       <li>
        Return the result of <a data-link-type="dfn" href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a> <var>p</var> with a fulfillment handler that performs the following substeps <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>: 
        <ol>
         <li>Let <var>itemsCopy</var> be a new <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-18">request to response map</a> that is a copy of its <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-19">request to response map</a>.
         <li>Let <var>addedRecords</var> be an empty array.
         <li>
          Try running the following substeps atomically: 
          <ol>
           <li>Let <var>resultArray</var> be an empty array.
           <li>
            For each <var>operation</var> in <var>operations</var> with the index <var>index</var>: 
            <ol>
             <li>If <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-type" id="ref-for-dom-cachebatchoperation-type-4">type</a></code> matches neither "delete" nor "put", <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code>TypeError</code>.
             <li>If <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-type" id="ref-for-dom-cachebatchoperation-type-5">type</a></code> matches "delete" and <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-response" id="ref-for-dom-cachebatchoperation-response-3">response</a></code> is not null, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code>TypeError</code>.
             <li>If the result of running <a href="#query-cache-algorithm">Query Cache</a> algorithm passing <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-4">request</a></code>, <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-options" id="ref-for-dom-cachebatchoperation-options-2">options</a></code>, and <var>addedRecords</var> as the arguments is not an empty array, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> an "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception.
             <li>Let <var>requestResponseArray</var> be the result of running <a href="#query-cache-algorithm">Query Cache</a> algorithm passing <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-5">request</a></code> and <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-options" id="ref-for-dom-cachebatchoperation-options-3">options</a></code> as the arguments.
             <li>
              For each <var>requestResponse</var> in <var>requestResponseArray</var>: 
              <ol>
               <li>If <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-type" id="ref-for-dom-cachebatchoperation-type-6">type</a></code> matches "delete", remove the corresponding <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-12">fetching record</a> from <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-20">request to response map</a>.
              </ol>
             <li>
              If <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-type" id="ref-for-dom-cachebatchoperation-type-7">type</a></code> matches "put", then: 
              <ol>
               <li>If <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-response" id="ref-for-dom-cachebatchoperation-response-4">response</a></code> is null, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code>TypeError</code>.
               <li>Let <var>r</var> be <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-6">request</a></code>'s associated <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>.
               <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code>TypeError</code>.
               <li>If <var>r</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-method">method</a> is not `<code>GET</code>`, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code>TypeError</code>.
               <li>If <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-options" id="ref-for-dom-cachebatchoperation-options-4">options</a></code> is not null, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code>TypeError</code>.
               <li>Set <var>requestResponseArray</var> to the result of running <a href="#query-cache-algorithm">Query Cache</a> algorithm passing <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-7">request</a></code>.
               <li>
                If <var>requestResponseArray</var> is not an empty array, then: 
                <ol>
                 <li>Let <var>requestResponse</var> be <var>requestResponseArray</var>[0].
                 <li>Let <var>fetchingRecord</var> be the corresponding <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-13">fetching record</a> for <var>requestResponse</var>[0] and <var>requestResponse</var>[1] in <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-21">request to response map</a>.
                 <li>Set <var>fetchingRecord</var>.[[key]] to <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-8">request</a></code> and <var>fetchingRecord</var>.[[value]] to <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-response" id="ref-for-dom-cachebatchoperation-response-5">response</a></code>.
                </ol>
               <li>
                Else: 
                <ol>
                 <li>Set a newly-created <a href="#dfn-fetching-record" id="ref-for-dfn-fetching-record-14">fetching record</a> {[[key]]: <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-request" id="ref-for-dom-cachebatchoperation-request-9">request</a></code>, [[value]]: <var>operation</var>.<code class="idl"><a data-link-type="idl" href="#dom-cachebatchoperation-response" id="ref-for-dom-cachebatchoperation-response-6">response</a></code>} to <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-22">request to response map</a>.
                </ol>
                <p class="note" role="note">The cache commit is allowed as long as the response’s headers are available.</p>
               <li>If the cache write operation in the previous two steps failed due to exceeding the granted quota limit, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#quotaexceedederror">QuotaExceededError</a></code>" exception.
               <li>Add an array [<var>operation</var>.<var>request</var>, <var>operation</var>.<var>response</var>] to <var>addedRecords</var>.
              </ol>
             <li>Add <var>operation</var>.<var>response</var> to <var>resultArray</var>.
            </ol>
           <li>Return <var>resultArray</var>.
          </ol>
         <li>
          And then, if an exception was <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">thrown</a>, then: 
          <ol>
           <li>Set the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#context-object">context object</a>’s <a href="#dfn-request-to-response-map" id="ref-for-dfn-request-to-response-map-23">request to response map</a> to <var>itemsCopy</var>.
           <li><a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">Throw</a> the exception
          </ol>
        </ol>
      </ol>
     </section>
    </section>
    <section>
     <h2 class="heading settled" id="extended-http-headers"><span class="content">Appendix B: Extended HTTP headers</span><a class="self-link" href="#extended-http-headers"></a></h2>
     <section>
      <h3 class="heading settled" id="service-worker-script-request"><span class="content">Service Worker Script Request</span><a class="self-link" href="#service-worker-script-request"></a></h3>
      <p>An HTTP request to <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-112">service worker</a>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-9">script resource</a> will include the following <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header">header</a>:</p>
      <dl>
       <dt>`<dfn data-dfn-type="dfn" data-noexport="" id="service-worker"><code>Service-Worker</code><a class="self-link" href="#service-worker"></a></dfn>`
       <dd>
        Indicates this request is a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-113">service worker</a>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-10">script resource</a> request. 
        <p class="note" role="note">This header helps administrators log the requests and detect threats.</p>
      </dl>
     </section>
     <section>
      <h3 class="heading settled" id="service-worker-script-response"><span class="content">Service Worker Script Response</span><a class="self-link" href="#service-worker-script-response"></a></h3>
      <p>An HTTP response to a <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-114">service worker</a>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-11">script resource</a> request can include the following <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-header">header</a>:</p>
      <dl>
       <dt>`<dfn data-dfn-type="dfn" data-noexport="" id="service-worker-allowed"><code>Service-Worker-Allowed</code><a class="self-link" href="#service-worker-allowed"></a></dfn>`
       <dd>
        Indicates the user agent will override the path restriction, which limits the maximum allowed <a href="#dfn-scope-url" id="ref-for-dfn-scope-url-19">scope url</a> that the script can <a href="#dfn-control" id="ref-for-dfn-control-5">control</a>, to the given value. 
        <p class="note" role="note">The value is a URL. If a relative URL is given, it is parsed against the script’s URL.</p>
      </dl>
      <div class="example" id="example-c971b856">
       <a class="self-link" href="#example-c971b856"></a> Default scope: 
<pre class="lang-js highlight"><span class="c1">// Maximum allowed scope defaults to the path the script sits in
</span><span class="c1">// "/js" in this example
</span>navigator<span class="p">.</span>serviceWorker<span class="p">.</span>register<span class="p">(</span><span class="s2">"/js/sw.js"</span><span class="p">)</span><span class="p">.</span>then<span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="p">)</span> <span class="p">{</span>
  console<span class="p">.</span>log<span class="p">(</span><span class="s2">"Install succeeded with the default scope '/js'."</span><span class="p">)</span><span class="p">;</span>
<span class="p">}</span><span class="p">)</span><span class="p">;</span>
</pre>
      </div>
      <div class="example" id="example-fc88e43e">
       <a class="self-link" href="#example-fc88e43e"></a> Upper path without Service-Worker-Allowed header: 
<pre class="lang-js highlight"><span class="c1">// Set the scope to an upper path of the script location
</span><span class="c1">// Response has no Service-Worker-Allowed header
</span>navigator<span class="p">.</span>serviceWorker<span class="p">.</span>register<span class="p">(</span><span class="s2">"/js/sw.js"</span><span class="p">,</span> <span class="p">{</span> scope<span class="o">:</span> <span class="s2">"/"</span> <span class="p">}</span><span class="p">)</span><span class="p">.</span><span class="k">catch</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="p">)</span> <span class="p">{</span>
  console<span class="p">.</span>error<span class="p">(</span><span class="s2">"Install failed due to the path restriction violation."</span><span class="p">)</span><span class="p">;</span>
<span class="p">}</span><span class="p">)</span><span class="p">;</span>
</pre>
      </div>
      <div class="example" id="example-a6511e54">
       <a class="self-link" href="#example-a6511e54"></a> Upper path with Service-Worker-Allowed header: 
<pre class="lang-js highlight"><span class="c1">// Set the scope to an upper path of the script location
</span><span class="c1">// Response included "Service-Worker-Allowed : /"
</span>navigator<span class="p">.</span>serviceWorker<span class="p">.</span>register<span class="p">(</span><span class="s2">"/js/sw.js"</span><span class="p">,</span> <span class="p">{</span> scope<span class="o">:</span> <span class="s2">"/"</span> <span class="p">}</span><span class="p">)</span><span class="p">.</span>then<span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="p">)</span> <span class="p">{</span>
  console<span class="p">.</span>log<span class="p">(</span><span class="s2">"Install succeeded as the max allowed scope was overriden to '/'."</span><span class="p">)</span><span class="p">;</span>
<span class="p">}</span><span class="p">)</span><span class="p">;</span>
</pre>
      </div>
      <div class="example" id="example-8e526533">
       <a class="self-link" href="#example-8e526533"></a> A path restriction voliation even with Service-Worker-Allowed header: 
<pre class="lang-js highlight"><span class="c1">// Set the scope to an upper path of the script location
</span><span class="c1">// Response included "Service-Worker-Allowed : /foo"
</span>navigator<span class="p">.</span>serviceWorker<span class="p">.</span>register<span class="p">(</span><span class="s2">"/foo/bar/sw.js"</span><span class="p">,</span> <span class="p">{</span> scope<span class="o">:</span> <span class="s2">"/"</span> <span class="p">}</span><span class="p">)</span><span class="p">.</span><span class="k">catch</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="p">)</span> <span class="p">{</span>
  console<span class="p">.</span>error<span class="p">(</span><span class="s2">"Install failed as the scope is still out of the overriden maximum allowed scope."</span><span class="p">)</span><span class="p">;</span>
<span class="p">}</span><span class="p">)</span><span class="p">;</span>
</pre>
      </div>
     </section>
     <section>
      <h3 class="heading settled" id="syntax"><span class="content">Syntax</span><a class="self-link" href="#syntax"></a></h3>
      <p><a data-link-type="biblio" href="#biblio-rfc5234">ABNF</a> for the values of the headers used by the <a href="#dfn-service-worker" id="ref-for-dfn-service-worker-115">service worker</a>’s <a href="#dfn-script-resource" id="ref-for-dfn-script-resource-12">script resource</a> requests and responses:</p>
<pre>Service-Worker = %x73.63.72.69.70.74 ; "script", case-sensitive
</pre>
      <p class="note" role="note">The validation of the Service-Worker-Allowed header’s values is done by URL parsing algorithm (in Update algorithm) instead of using ABNF.</p>
     </section>
    </section>
    <section>
     <h2 class="heading settled" data-level="9" id="acknowledgements"><span class="secno">9. </span><span class="content">Acknowledgements</span><a class="self-link" href="#acknowledgements"></a></h2>
     <p>Deep thanks go to Andrew Betts for organizing and hosting a small workshop of like-minded individuals including: Jake Archibald, Jackson Gabbard, Tobie Langel, Robin Berjon, Patrick Lauke, Christian Heilmann. From the clarity of the day’s discussions and the use-cases outlined there, much has become possible. Further thanks to Andrew for raising consciousness about the offline problem. His organization of EdgeConf and inclusion of Offline as a persistent topic there has created many opportunities and connections that have enabled this work to progress.</p>
     <p>Anne van Kesteren has generously lent his encyclopedic knowledge of Web Platform arcana and standards development experience throughout the development of the service worker. This specification would be incomplete without his previous work in describing the real-world behavior of URLs, HTTP Fetch, Promises, and DOM. Similarly, this specification would not be possible without Ian Hickson’s rigorous Web Worker spec. Much thanks to him.</p>
     <p>In no particular order, deep gratitude for design guidance and discussion goes to: Jungkee Song, Alec Flett, David Barrett-Kahn, Aaron Boodman, Michael Nordman, Tom Ashworth, Kinuko Yasuda, Darin Fisher, Jonas Sicking, Jesús Leganés Combarro, Mark Christian, Dave Hermann, Yehuda Katz, François Remy, Ilya Grigorik, Will Chan, Domenic Denicola, Nikhil Marathe, Yves Lafon, Adam Barth, Greg Simon, Devdatta Akhawe, Dominic Cooney, Jeffrey Yasskin, Joshua Bell, Boris Zbarsky, Matt Falkenhagen, Tobie Langel, Gavin Peters, Ben Kelly, Hiroki Nakagawa, Jake Archibald, Josh Soref, Jinho Bang and Yutaka Hirano.</p>
     <p>Jason Weber, Chris Wilson, Paul Kinlan, Ehsan Akhgari, and Daniel Austin have provided valuable, well-timed feedback on requirements and the standardization process.</p>
     <p>The authors would also like to thank Dimitri Glazkov for his scripts and formatting tools which have been essential in the production of this specification. The authors are also grateful for his considerable guidance.</p>
     <p>Thanks also to Vivian Cromwell, Greg Simon, Alex Komoroske, Wonsuk Lee, and Seojin Kim for their considerable professional support.</p>
    </section>
   </section>
  </main>
  <div data-fill-with="conformance">
   <h2 class="no-ref no-num heading settled" id="conformance"><span class="content">Conformance</span><a class="self-link" href="#conformance"></a></h2>
   <h3 class="no-ref no-num heading settled" id="conventions"><span class="content">Document conventions</span><a class="self-link" href="#conventions"></a></h3>
   <p>Conformance requirements are expressed with a combination of
    descriptive assertions and RFC 2119 terminology. The key words “MUST”,
    “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
    “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
    document are to be interpreted as described in RFC 2119.
    However, for readability, these words do not appear in all uppercase
    letters in this specification. </p>
   <p>All of the text of this specification is normative except sections
    explicitly marked as non-normative, examples, and notes. <a data-link-type="biblio" href="#biblio-rfc2119">[RFC2119]</a></p>
   <p>Examples in this specification are introduced with the words “for example”
    or are set apart from the normative text with <code>class="example"</code>,
    like this: </p>
   <div class="example" id="example-f839f6c8">
    <a class="self-link" href="#example-f839f6c8"></a> 
    <p>This is an example of an informative example.</p>
   </div>
   <p>Informative notes begin with the word “Note” and are set apart from the
    normative text with <code>class="note"</code>, like this: </p>
   <p class="note" role="note">Note, this is an informative note.</p>
   <h3 class="no-ref no-num heading settled" id="conformant-algorithms"><span class="content">Conformant Algorithms</span><a class="self-link" href="#conformant-algorithms"></a></h3>
   <p>Requirements phrased in the imperative as part of algorithms (such as
    "strip any leading space characters" or "return false and abort these
    steps") are to be interpreted with the meaning of the key word ("must",
    "should", "may", etc) used in introducing the algorithm.</p>
   <p>Conformance requirements phrased as algorithms or specific steps can be
    implemented in any manner, so long as the end result is <dfn data-dfn-type="dfn" data-lt="processing equivalence" data-noexport="" id="dfn-processing-equivalence">equivalent<a class="self-link" href="#dfn-processing-equivalence"></a></dfn>. In
    particular, the algorithms defined in this specification are intended to
    be easy to understand and are not intended to be performant. Implementers
    are encouraged to optimize.</p>
  </div>
<script src="https://www.w3.org/scripts/TR/2016/fixup.js"></script>
  <h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2>
  <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3>
  <ul class="index">
   <li><a href="#service-worker-global-scope-activate-event">activate</a><span>, in §4.7</span>
   <li><a href="#dom-serviceworkerstate-activated">activated</a><span>, in §3.1</span>
   <li><a href="#dom-serviceworkerstate-activated">"activated"</a><span>, in §3.1</span>
   <li><a href="#dom-serviceworkerstate-activating">activating</a><span>, in §3.1</span>
   <li><a href="#dom-serviceworkerstate-activating">"activating"</a><span>, in §3.1</span>
   <li><a href="#service-worker-registration-active-attribute">active</a><span>, in §3.2.3</span>
   <li>
    active worker
    <ul>
     <li><a href="#dfn-active-worker">dfn for service worker registration</a><span>, in §2.2</span>
     <li><a href="#dfn-service-worker-client-active-worker">dfn for service worker client</a><span>, in §2.3</span>
    </ul>
   <li><a href="#cache-addAll-method">addAll(requests)</a><span>, in §5.4.4</span>
   <li><a href="#cache-add-method">add(request)</a><span>, in §5.4.3</span>
   <li><a href="#dom-clienttype-all">all</a><span>, in §4.3</span>
   <li><a href="#dom-clienttype-all">"all"</a><span>, in §4.3</span>
   <li><a href="#dom-frametype-auxiliary">"auxiliary"</a><span>, in §4.2</span>
   <li><a href="#dom-frametype-auxiliary">auxiliary</a><span>, in §4.2</span>
   <li><a href="#cache-interface">Cache</a><span>, in §5.4</span>
   <li><a href="#dictdef-cache-cachebatchoperation">CacheBatchOperation</a><span>, in §5.4</span>
   <li><a href="#dom-cachequeryoptions-cachename">cacheName</a><span>, in §5.4</span>
   <li><a href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a><span>, in §5.4</span>
   <li><a href="#global-caches-attribute">caches</a><span>, in §5.3.1</span>
   <li><a href="#cache-storage-interface">CacheStorage</a><span>, in §5.5</span>
   <li><a href="#clients-claim-method">claim()</a><span>, in §4.3.4</span>
   <li><a href="#client-interface">Client</a><span>, in §4.2</span>
   <li><a href="#dfn-job-client">client</a><span>, in §Unnumbered section</span>
   <li>
    clientId
    <ul>
     <li><a href="#dom-fetcheventinit-clientid">dict-member for FetchEventInit</a><span>, in §4.5</span>
     <li><a href="#fetch-event-clientid-attribute">attribute for FetchEvent</a><span>, in §4.5.2</span>
    </ul>
   <li><a href="#dfn-client-message-queue">client message queue</a><span>, in §3.4</span>
   <li><a href="#dictdef-clients-clientqueryoptions">ClientQueryOptions</a><span>, in §4.3</span>
   <li><a href="#clients-interface">Clients</a><span>, in §4.3</span>
   <li><a href="#service-worker-global-scope-clients-attribute">clients</a><span>, in §4.1.1</span>
   <li><a href="#enumdef-clients-clienttype">ClientType</a><span>, in §4.3</span>
   <li><a href="#dfn-containing-service-worker-registration">containing service worker registration</a><span>, in §2.1</span>
   <li><a href="#dfn-control">control</a><span>, in §2.4</span>
   <li><a href="#service-worker-container-controller-attribute">controller</a><span>, in §3.4.1</span>
   <li><a href="#service-worker-container-controllerchange-event">controllerchange</a><span>, in §3.6</span>
   <li>
    data
    <ul>
     <li><a href="#dom-serviceworkermessageeventinit-data">dict-member for ServiceWorkerMessageEventInit</a><span>, in §3.5</span>
     <li><a href="#serviceworkermessage-event-data-attribute">attribute for ServiceWorkerMessageEvent</a><span>, in §3.5.1</span>
     <li><a href="#dom-extendablemessageeventinit-data">dict-member for ExtendableMessageEventInit</a><span>, in §4.6</span>
     <li><a href="#extendablemessage-event-data-attribute">attribute for ExtendableMessageEvent</a><span>, in §4.6.1</span>
    </ul>
   <li><a href="#dfn-dedicatedworker-client">dedicated worker client</a><span>, in §2.3</span>
   <li><a href="#cache-storage-delete-method">delete(cacheName)</a><span>, in §5.5.4</span>
   <li><a href="#cache-delete-method">delete(request)</a><span>, in §5.4.6</span>
   <li><a href="#cache-delete-method">delete(request, options)</a><span>, in §5.4.6</span>
   <li><a href="#dfn-job-equivalent">equivalent</a><span>, in §Unnumbered section</span>
   <li><a href="#extendable-event-interface">ExtendableEvent</a><span>, in §4.4</span>
   <li><a href="#dictdef-extendableeventinit">ExtendableEventInit</a><span>, in §4.4</span>
   <li><a href="#dom-extendableevent-extendableevent">ExtendableEvent(type)</a><span>, in §4.4</span>
   <li><a href="#dom-extendableevent-extendableevent">ExtendableEvent(type, eventInitDict)</a><span>, in §4.4</span>
   <li><a href="#extendablemessage-event-interface">ExtendableMessageEvent</a><span>, in §4.6</span>
   <li><a href="#dictdef-extendablemessageevent-extendablemessageeventinit">ExtendableMessageEventInit</a><span>, in §4.6</span>
   <li><a href="#dom-extendablemessageevent-extendablemessageevent">ExtendableMessageEvent(type)</a><span>, in §4.6</span>
   <li><a href="#dom-extendablemessageevent-extendablemessageevent">ExtendableMessageEvent(type, eventInitDict)</a><span>, in §4.6</span>
   <li><a href="#dfn-extend-lifetime-promises">extend lifetime promises</a><span>, in §4.4</span>
   <li><a href="#extensions-allowed-flag">extensions allowed flag</a><span>, in §4.4</span>
   <li><a href="#service-worker-global-scope-fetch-event">fetch</a><span>, in §4.7</span>
   <li><a href="#fetch-event-interface">FetchEvent</a><span>, in §4.5</span>
   <li><a href="#dictdef-fetchevent-fetcheventinit">FetchEventInit</a><span>, in §4.5</span>
   <li><a href="#dom-fetchevent-fetchevent">FetchEvent(type, eventInitDict)</a><span>, in §4.5</span>
   <li><a href="#dfn-fetching-record">fetching record</a><span>, in §5.1</span>
   <li><a href="#client-focus-method">focus()</a><span>, in §4.2.7</span>
   <li><a href="#client-focused-attribute">focused</a><span>, in §4.2.6</span>
   <li><a href="#dfn-service-worker-client-focusstate">focus state</a><span>, in §4.2</span>
   <li><a href="#dfn-job-force-bypass-cache-flag">force bypass cache flag</a><span>, in §Unnumbered section</span>
   <li><a href="#contextframetype-enum">FrameType</a><span>, in §4.2.2</span>
   <li><a href="#dfn-service-worker-client-frame-type">frame type</a><span>, in §2.3</span>
   <li><a href="#client-frametype-attribute">frameType</a><span>, in §4.2.2</span>
   <li><a href="#dfn-functional-events">functional events</a><span>, in §2.1</span>
   <li><a href="#clients-get-method">get(id)</a><span>, in §4.3.1</span>
   <li><a href="#service-worker-container-getregistration-method">getRegistration()</a><span>, in §3.4.4</span>
   <li><a href="#service-worker-container-getregistration-method">getRegistration(clientURL)</a><span>, in §3.4.4</span>
   <li><a href="#service-worker-container-getregistrations-method">getRegistrations()</a><span>, in §3.4.5</span>
   <li><a href="#cachestorage-global-object">global object</a><span>, in §5.5</span>
   <li><a href="#dfn-handle-fetch-task-source">handle fetch task source</a><span>, in §2.5</span>
   <li><a href="#dfn-handle-functional-event-task-source">handle functional event task source</a><span>, in §2.5</span>
   <li><a href="#cache-storage-has-method">has(cacheName)</a><span>, in §5.5.2</span>
   <li><a href="#dfn-has-ever-been-evaluated-flag">has ever been evaluated flag</a><span>, in §2.1</span>
   <li><a href="#dfn-https-state">HTTPS state</a><span>, in §2.1</span>
   <li>
    id
    <ul>
     <li><a href="#dfn-service-worker-id">dfn for service worker</a><span>, in §2.1</span>
     <li><a href="#dfn-service-worker-client-id">dfn for service worker client</a><span>, in §2.3</span>
     <li><a href="#client-id-attribute">attribute for Client</a><span>, in §4.2.3</span>
    </ul>
   <li><a href="#dom-cachequeryoptions-ignoremethod">ignoreMethod</a><span>, in §5.4</span>
   <li><a href="#dom-cachequeryoptions-ignoresearch">ignoreSearch</a><span>, in §5.4</span>
   <li><a href="#dom-cachequeryoptions-ignorevary">ignoreVary</a><span>, in §5.4</span>
   <li><a href="#dfn-imported-scripts-updated-flag">imported scripts updated flag</a><span>, in §2.1</span>
   <li><a href="#importscripts-method">importScripts(urls)</a><span>, in §6.3.2</span>
   <li><a href="#dom-clientqueryoptions-includeuncontrolled">includeUncontrolled</a><span>, in §4.3</span>
   <li><a href="#dfn-incumbent-record">incumbent record</a><span>, in §5.1</span>
   <li><a href="#service-worker-global-scope-install-event">install</a><span>, in §4.7</span>
   <li><a href="#dom-serviceworkerstate-installed">installed</a><span>, in §3.1</span>
   <li><a href="#dom-serviceworkerstate-installed">"installed"</a><span>, in §3.1</span>
   <li><a href="#dom-serviceworkerstate-installing">"installing"</a><span>, in §3.1</span>
   <li>
    installing
    <ul>
     <li><a href="#dom-serviceworkerstate-installing">enum-value for ServiceWorkerState</a><span>, in §3.1</span>
     <li><a href="#service-worker-registration-installing-attribute">attribute for ServiceWorkerRegistration</a><span>, in §3.2.1</span>
    </ul>
   <li><a href="#dfn-installing-worker">installing worker</a><span>, in §2.2</span>
   <li>
    isReload
    <ul>
     <li><a href="#dom-fetcheventinit-isreload">dict-member for FetchEventInit</a><span>, in §4.5</span>
     <li><a href="#fetch-event-isreload-attribute">attribute for FetchEvent</a><span>, in §4.5.3</span>
    </ul>
   <li><a href="#dfn-job">job</a><span>, in §Unnumbered section</span>
   <li><a href="#dfn-job-promise">job promise</a><span>, in §Unnumbered section</span>
   <li><a href="#dfn-job-queue">job queue</a><span>, in §Unnumbered section</span>
   <li><a href="#dfn-job-type">job type</a><span>, in §Unnumbered section</span>
   <li>
    keys()
    <ul>
     <li><a href="#cache-keys-method">method for Cache</a><span>, in §5.4.7</span>
     <li><a href="#cache-storage-keys-method">method for CacheStorage</a><span>, in §5.5.5</span>
    </ul>
   <li><a href="#cache-keys-method">keys(request)</a><span>, in §5.4.7</span>
   <li><a href="#cache-keys-method">keys(request, options)</a><span>, in §5.4.7</span>
   <li>
    lastEventId
    <ul>
     <li><a href="#dom-serviceworkermessageeventinit-lasteventid">dict-member for ServiceWorkerMessageEventInit</a><span>, in §3.5</span>
     <li><a href="#serviceworkermessage-event-lasteventid-attribute">attribute for ServiceWorkerMessageEvent</a><span>, in §3.5.3</span>
     <li><a href="#dom-extendablemessageeventinit-lasteventid">dict-member for ExtendableMessageEventInit</a><span>, in §4.6</span>
     <li><a href="#extendablemessage-event-lasteventid-attribute">attribute for ExtendableMessageEvent</a><span>, in §4.6.3</span>
    </ul>
   <li><a href="#dfn-last-update-check-time">last update check time</a><span>, in §2.2</span>
   <li><a href="#dfn-lifecycle-events">lifecycle events</a><span>, in §2.1</span>
   <li><a href="#dfn-job-list-of-equivalent-jobs">list of equivalent jobs</a><span>, in §Unnumbered section</span>
   <li>
    matchAll()
    <ul>
     <li><a href="#clients-matchall-method">method for Clients</a><span>, in §4.3.2</span>
     <li><a href="#cache-matchall-method">method for Cache</a><span>, in §5.4.2</span>
    </ul>
   <li><a href="#clients-matchall-method">matchAll(options)</a><span>, in §4.3.2</span>
   <li><a href="#cache-matchall-method">matchAll(request)</a><span>, in §5.4.2</span>
   <li><a href="#cache-matchall-method">matchAll(request, options)</a><span>, in §5.4.2</span>
   <li>
    match(request)
    <ul>
     <li><a href="#cache-match-method">method for Cache</a><span>, in §5.4.1</span>
     <li><a href="#cache-storage-match-method">method for CacheStorage</a><span>, in §5.5.1</span>
    </ul>
   <li>
    match(request, options)
    <ul>
     <li><a href="#cache-match-method">method for Cache</a><span>, in §5.4.1</span>
     <li><a href="#cache-storage-match-method">method for CacheStorage</a><span>, in §5.5.1</span>
    </ul>
   <li>
    message
    <ul>
     <li><a href="#service-worker-container-message-event">event for ServiceWorkerContainer</a><span>, in §3.6</span>
     <li><a href="#service-worker-global-scope-message-event">event for ServiceWorkerGlobalScope</a><span>, in §4.7</span>
    </ul>
   <li><a href="#dfn-name-to-cache-map">name to cache map</a><span>, in §5.1</span>
   <li><a href="#client-navigate-method">navigate(url)</a><span>, in §4.2.8</span>
   <li><a href="#dom-frametype-nested">"nested"</a><span>, in §4.2</span>
   <li><a href="#dom-frametype-nested">nested</a><span>, in §4.2</span>
   <li><a href="#dom-frametype-none">"none"</a><span>, in §4.2</span>
   <li><a href="#dom-frametype-none">none</a><span>, in §4.2</span>
   <li><a href="#service-worker-global-scope-onactivate-attribute">onactivate</a><span>, in §4.1.4</span>
   <li><a href="#service-worker-container-oncontrollerchange-attribute">oncontrollerchange</a><span>, in §3.4.7</span>
   <li><a href="#service-worker-global-scope-onfetch-attribute">onfetch</a><span>, in §4.1.4</span>
   <li><a href="#service-worker-global-scope-oninstall-attribute">oninstall</a><span>, in §4.1.4</span>
   <li>
    onmessage
    <ul>
     <li><a href="#service-worker-container-onmessage-attribute">attribute for ServiceWorkerContainer</a><span>, in §3.4.7</span>
     <li><a href="#service-worker-global-scope-onmessage-attribute">attribute for ServiceWorkerGlobalScope</a><span>, in §4.1.4</span>
    </ul>
   <li><a href="#service-worker-onstatechange-attribute">onstatechange</a><span>, in §3.1.4</span>
   <li><a href="#service-worker-registration-onupdatefound-attribute">onupdatefound</a><span>, in §3.2.7</span>
   <li><a href="#cache-storage-open-method">open(cacheName)</a><span>, in §5.5.3</span>
   <li><a href="#clients-openwindow-method">openWindow(url)</a><span>, in §4.3.3</span>
   <li><a href="#dom-cachebatchoperation-options">options</a><span>, in §5.4</span>
   <li>
    origin
    <ul>
     <li><a href="#dom-serviceworkermessageeventinit-origin">dict-member for ServiceWorkerMessageEventInit</a><span>, in §3.5</span>
     <li><a href="#serviceworkermessage-event-origin-attribute">attribute for ServiceWorkerMessageEvent</a><span>, in §3.5.2</span>
     <li><a href="#dom-extendablemessageeventinit-origin">dict-member for ExtendableMessageEventInit</a><span>, in §4.6</span>
     <li><a href="#extendablemessage-event-origin-attribute">attribute for ExtendableMessageEvent</a><span>, in §4.6.2</span>
    </ul>
   <li>
    ports
    <ul>
     <li><a href="#dom-serviceworkermessageeventinit-ports">dict-member for ServiceWorkerMessageEventInit</a><span>, in §3.5</span>
     <li><a href="#serviceworkermessage-event-ports-attribute">attribute for ServiceWorkerMessageEvent</a><span>, in §3.5.5</span>
     <li><a href="#dom-extendablemessageeventinit-ports">dict-member for ExtendableMessageEventInit</a><span>, in §4.6</span>
     <li><a href="#extendablemessage-event-ports-attribute">attribute for ExtendableMessageEvent</a><span>, in §4.6.5</span>
    </ul>
   <li><a href="#client-postmessage-method">postMessage(message)</a><span>, in §4.2.4</span>
   <li>
    postMessage(message, transfer)
    <ul>
     <li><a href="#service-worker-postmessage-method">method for ServiceWorker</a><span>, in §3.1.3</span>
     <li><a href="#client-postmessage-method">method for Client</a><span>, in §4.2.4</span>
    </ul>
   <li><a href="#fetchevent-potential-response">potential response</a><span>, in §4.5</span>
   <li><a href="#dfn-processing-equivalence">processing equivalence</a><span>, in §Unnumbered section</span>
   <li><a href="#cache-put-method">put(request, response)</a><span>, in §5.4.5</span>
   <li><a href="#service-worker-container-ready-attribute">ready</a><span>, in §3.4.2</span>
   <li><a href="#dfn-ready-promise">ready promise</a><span>, in §3.4</span>
   <li><a href="#dom-serviceworkerstate-redundant">"redundant"</a><span>, in §3.1</span>
   <li><a href="#dom-serviceworkerstate-redundant">redundant</a><span>, in §3.1</span>
   <li><a href="#dfn-registration-script-url">registering script url</a><span>, in §2.2</span>
   <li><a href="#service-worker-container-register-method">register(scriptURL)</a><span>, in §3.4.3</span>
   <li><a href="#service-worker-container-register-method">register(scriptURL, options)</a><span>, in §3.4.3</span>
   <li><a href="#service-worker-global-scope-scope-attribute">registration</a><span>, in §4.1.2</span>
   <li><a href="#dictdef-serviceworkercontainer-registrationoptions">RegistrationOptions</a><span>, in §3.4</span>
   <li>
    request
    <ul>
     <li><a href="#dom-fetcheventinit-request">dict-member for FetchEventInit</a><span>, in §4.5</span>
     <li><a href="#fetch-event-request-attribute">attribute for FetchEvent</a><span>, in §4.5.1</span>
     <li><a href="#dom-cachebatchoperation-request">dict-member for CacheBatchOperation</a><span>, in §5.4</span>
    </ul>
   <li><a href="#dfn-request-to-response-map">request to response map</a><span>, in §5.1</span>
   <li><a href="#respond-with-entered-flag">respond-with entered flag</a><span>, in §4.5</span>
   <li><a href="#respond-with-error-flag">respond-with error flag</a><span>, in §4.5</span>
   <li><a href="#fetch-event-respondwith-method">respondWith(r)</a><span>, in §4.5.4</span>
   <li><a href="#dom-cachebatchoperation-response">response</a><span>, in §5.4</span>
   <li>
    scope
    <ul>
     <li><a href="#service-worker-registration-scope-attribute">attribute for ServiceWorkerRegistration</a><span>, in §3.2.4</span>
     <li><a href="#dom-registrationoptions-scope">dict-member for RegistrationOptions</a><span>, in §3.4</span>
    </ul>
   <li><a href="#dfn-scope-to-registration-map">scope to registration map</a><span>, in §Unnumbered section</span>
   <li>
    scope url
    <ul>
     <li><a href="#dfn-scope-url">dfn for service worker registration</a><span>, in §2.2</span>
     <li><a href="#dfn-job-scope-url">definition of</a><span>, in §Unnumbered section</span>
    </ul>
   <li><a href="#dfn-script-resource">script resource</a><span>, in §2.1</span>
   <li><a href="#dfn-script-resource-map">script resource map</a><span>, in §2.1</span>
   <li>
    script url
    <ul>
     <li><a href="#dfn-script-url">dfn for service worker</a><span>, in §2.1</span>
     <li><a href="#dfn-job-script-url">definition of</a><span>, in §Unnumbered section</span>
    </ul>
   <li><a href="#service-worker-url-attribute">scriptURL</a><span>, in §3.1.1</span>
   <li><a href="#dfn-service-worker-registration-selection">selection</a><span>, in §2.4</span>
   <li><a href="#service-worker">Service-Worker</a><span>, in §Unnumbered section</span>
   <li><a href="#service-worker-interface">ServiceWorker</a><span>, in §3.1</span>
   <li><a href="#navigator-service-worker-attribute">serviceWorker</a><span>, in §3.3</span>
   <li>
    service worker
    <ul>
     <li><a href="#dfn-service-worker">dfn for </a><span>, in §2.1</span>
     <li><a href="#dfn-service-worker-global-scope-service-worker">dfn for ServiceWorkerGlobalScope</a><span>, in §4.1</span>
    </ul>
   <li><a href="#service-worker-allowed">Service-Worker-Allowed</a><span>, in §Unnumbered section</span>
   <li>
    service worker client
    <ul>
     <li><a href="#dfn-service-worker-client">dfn for </a><span>, in §2.3</span>
     <li><a href="#dfn-service-worker-container-interface-client">dfn for ServiceWorkerContainer</a><span>, in §3.4</span>
     <li><a href="#dfn-service-worker-client-client">dfn for Client</a><span>, in §4.2</span>
    </ul>
   <li><a href="#service-worker-container-interface">ServiceWorkerContainer</a><span>, in §3.4</span>
   <li><a href="#service-worker-global-scope-interface">ServiceWorkerGlobalScope</a><span>, in §4.1</span>
   <li><a href="#serviceworkermessage-event-interface">ServiceWorkerMessageEvent</a><span>, in §3.5</span>
   <li><a href="#dictdef-serviceworkermessageevent-serviceworkermessageeventinit">ServiceWorkerMessageEventInit</a><span>, in §3.5</span>
   <li><a href="#dom-serviceworkermessageevent-serviceworkermessageevent">ServiceWorkerMessageEvent(type)</a><span>, in §3.5</span>
   <li><a href="#dom-serviceworkermessageevent-serviceworkermessageevent">ServiceWorkerMessageEvent(type, eventInitDict)</a><span>, in §3.5</span>
   <li><a href="#service-worker-registration-interface">ServiceWorkerRegistration</a><span>, in §3.2</span>
   <li>
    service worker registration
    <ul>
     <li><a href="#dfn-service-worker-registration">dfn for </a><span>, in §2.2</span>
     <li><a href="#dfn-service-worker-registration-interface-service-worker-registration">dfn for ServiceWorkerRegistration</a><span>, in §3.2</span>
    </ul>
   <li><a href="#service-worker-state-enum">ServiceWorkerState</a><span>, in §3.1.2</span>
   <li><a href="#dfn-set-of-event-types-to-handle">set of event types to handle</a><span>, in §2.1</span>
   <li><a href="#dom-clienttype-sharedworker">sharedworker</a><span>, in §4.3</span>
   <li><a href="#dom-clienttype-sharedworker">"sharedworker"</a><span>, in §4.3</span>
   <li><a href="#dfn-sharedworker-client">shared worker client</a><span>, in §2.3</span>
   <li><a href="#service-worker-global-scope-skipwaiting-method">skipWaiting()</a><span>, in §4.1.3</span>
   <li><a href="#dfn-skip-waiting-flag">skip waiting flag</a><span>, in §2.1</span>
   <li>
    source
    <ul>
     <li><a href="#dom-serviceworkermessageeventinit-source">dict-member for ServiceWorkerMessageEventInit</a><span>, in §3.5</span>
     <li><a href="#serviceworkermessage-event-source-attribute">attribute for ServiceWorkerMessageEvent</a><span>, in §3.5.4</span>
     <li><a href="#dom-extendablemessageeventinit-source">dict-member for ExtendableMessageEventInit</a><span>, in §4.6</span>
     <li><a href="#extendablemessage-event-source-attribute">attribute for ExtendableMessageEvent</a><span>, in §4.6.4</span>
    </ul>
   <li><a href="#service-worker-container-startMessages-method">startMessages()</a><span>, in §3.4.6</span>
   <li>
    state
    <ul>
     <li><a href="#dfn-state">dfn for service worker</a><span>, in §2.1</span>
     <li><a href="#service-worker-state-attribute">attribute for ServiceWorker</a><span>, in §3.1.2</span>
    </ul>
   <li><a href="#service-worker-statechange-event">statechange</a><span>, in §3.6</span>
   <li><a href="#dfn-service-worker-registration-task-queue">task queues</a><span>, in §2.2</span>
   <li><a href="#dom-frametype-top-level">top-level</a><span>, in §4.2</span>
   <li><a href="#dom-frametype-top-level">"top-level"</a><span>, in §4.2</span>
   <li>
    type
    <ul>
     <li><a href="#dfn-type">dfn for service worker</a><span>, in §2.1</span>
     <li><a href="#dom-registrationoptions-type">dict-member for RegistrationOptions</a><span>, in §3.4</span>
     <li><a href="#dom-clientqueryoptions-type">dict-member for ClientQueryOptions</a><span>, in §4.3</span>
     <li><a href="#dom-cachebatchoperation-type">dict-member for CacheBatchOperation</a><span>, in §5.4</span>
    </ul>
   <li><a href="#dfn-uninstalling-flag">uninstalling flag</a><span>, in §2.2</span>
   <li><a href="#service-worker-registration-unregister-method">unregister()</a><span>, in §3.2.6</span>
   <li><a href="#service-worker-registration-update-method">update()</a><span>, in §3.2.5</span>
   <li><a href="#service-worker-registration-updatefound-event">updatefound</a><span>, in §3.6</span>
   <li><a href="#client-url-attribute">url</a><span>, in §4.2.1</span>
   <li><a href="#dfn-use">using</a><span>, in §2.4</span>
   <li><a href="#dfn-service-worker-client-visibilitystate">visibility state</a><span>, in §4.2</span>
   <li><a href="#client-visibilitystate-attribute">visibilityState</a><span>, in §4.2.5</span>
   <li><a href="#service-worker-registration-waiting-attribute">waiting</a><span>, in §3.2.2</span>
   <li><a href="#dfn-waiting-worker">waiting worker</a><span>, in §2.2</span>
   <li><a href="#wait-to-respond-flag">wait to respond flag</a><span>, in §4.5</span>
   <li><a href="#extendable-event-waituntil-method">waitUntil(f)</a><span>, in §4.4.1</span>
   <li><a href="#dom-clienttype-window">window</a><span>, in §4.3</span>
   <li><a href="#dom-clienttype-window">"window"</a><span>, in §4.3</span>
   <li><a href="#dfn-window-client">window client</a><span>, in §2.3</span>
   <li><a href="#window-client-interface">WindowClient</a><span>, in §4.2</span>
   <li><a href="#dom-clienttype-worker">worker</a><span>, in §4.3</span>
   <li><a href="#dom-clienttype-worker">"worker"</a><span>, in §4.3</span>
   <li><a href="#dfn-worker-client">worker client</a><span>, in §2.3</span>
   <li><a href="#dfn-job-worker-type">worker type</a><span>, in §Unnumbered section</span>
  </ul>
  <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3>
  <ul class="index">
   <li>
    <a data-link-type="biblio">[CSP2]</a> defines the following terms:
    <ul>
     <li><a href="https://w3c.github.io/webappsec-csp/2/#enforce">enforce</a>
     <li><a href="https://w3c.github.io/webappsec-csp/2/#monitor">monitor</a>
    </ul>
   <li>
    <a data-link-type="biblio">[WHATWG-DOM]</a> defines the following terms:
    <ul>
     <li><a href="https://dom.spec.whatwg.org/#document">Document</a>
     <li><a href="https://dom.spec.whatwg.org/#event">Event</a>
     <li><a href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a>
     <li><a href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a>
     <li><a href="https://dom.spec.whatwg.org/#canceled-flag">canceled flag</a>
     <li><a href="https://dom.spec.whatwg.org/#context-object">context object</a>
     <li><a href="https://dom.spec.whatwg.org/#concept-event-dispatch">dispatch</a>
     <li><a href="https://dom.spec.whatwg.org/#dispatch-flag">dispatch flag</a>
     <li><a href="https://dom.spec.whatwg.org/#concept-event">event</a>
     <li><a href="https://dom.spec.whatwg.org/#concept-event-listener">event listener</a>
     <li><a href="https://dom.spec.whatwg.org/#stop-immediate-propagation-flag">stop immediate propagation flag</a>
     <li><a href="https://dom.spec.whatwg.org/#stop-propagation-flag">stop propagation flag</a>
    </ul>
   <li>
    <a data-link-type="biblio">[dom-ls]</a> defines the following terms:
    <ul>
     <li><a href="https://dom.spec.whatwg.org/#ascii-case-insensitive">ascii case-insensitive</a>
    </ul>
   <li>
    <a data-link-type="biblio">[ECMASCRIPT]</a> defines the following terms:
    <ul>
     <li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist">[[call]]</a>
     <li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">assert</a>
     <li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">list</a>
     <li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-map-objects">map objects</a>
     <li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects">promise</a>
     <li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">record</a>
    </ul>
   <li>
    <a data-link-type="biblio">[FETCH]</a> defines the following terms:
    <ul>
     <li><a href="https://fetch.spec.whatwg.org/#headers">Headers</a>
     <li><a href="https://fetch.spec.whatwg.org/#request">Request</a>
     <li><a href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a>
     <li><a href="https://fetch.spec.whatwg.org/#response">Response</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-filtered-response-basic">basic filtered response</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-response-body">body</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-cache-mode">cache mode</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-cancel-readablestream">cancel a readablestream</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-client">client</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-close-readablestream">close readablestream</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-construct-readablestream">construct a readablestream</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-filtered-response-cors">cors filtered response</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-destination">destination</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-body-disturbed">disturbed</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-empty-readablestream">empty</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-enqueue-readablestream">enqueue a chunk to readablestream</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-error-readablestream">error readablestream</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-readablestream-errored">errored</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-header-extract-mime-type">extract a mime type</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a>
     <li><a href="https://fetch.spec.whatwg.org/#dom-global-fetch">fetch(input, init)</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-filtered-response">filtered response</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-get-reader">get a reader</a>
     <li><a href="https://fetch.spec.whatwg.org/#dom-headers-get">get(name)</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-headers-guard">guard</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-header">header</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a>
     <li><a href="https://fetch.spec.whatwg.org/#dom-request-headers">headers</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-http-fetch">http fetch</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-initiator">initiator</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-body-locked">locked</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-method">method</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-header-name">name</a>
     <li><a href="https://fetch.spec.whatwg.org/#navigation-request">navigation request</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-network-error">network error</a>
     <li><a href="https://fetch.spec.whatwg.org/#non-subresource-request">non-subresource request</a>
     <li><a href="https://fetch.spec.whatwg.org/#ok-status">ok status</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque">opaque filtered response</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-header-parse">parsing</a>
     <li><a href="https://fetch.spec.whatwg.org/#potential-navigation-or-subresource-request">potential-navigation-or-subresource request</a>
     <li><a href="https://fetch.spec.whatwg.org/#process-response">process response</a>
     <li><a href="https://fetch.spec.whatwg.org/#process-response-end-of-file">process response end-of-file</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-read-chunk-from-readablestream">read a chunk from a readablestream</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream">read all bytes</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-readablestream">readablestream</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-redirect-mode">redirect mode</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-request">request</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-response-response">response</a>
     <li><a href="https://fetch.spec.whatwg.org/#skip-service-worker-flag">skip service worker flag</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-response-status">status</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-body-stream">stream</a>
     <li><a href="https://fetch.spec.whatwg.org/#subresource-request">subresource request</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-fetch-terminate">terminate</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-response-termination-reason">termination reason</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-response-type">type</a>
     <li><a href="https://fetch.spec.whatwg.org/#concept-request-url">url</a>
    </ul>
   <li>
    <a data-link-type="biblio">[HTML]</a> defines the following terms:
    <ul>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#abstractworker">AbstractWorker</a>
     <li><a href="https://html.spec.whatwg.org/multipage/indices.html#event-domcontentloaded">DOMContentLoaded</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a>
     <li><a href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#sharedworkerglobalscope">SharedWorkerGlobalScope</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#window">Window</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#worker">Worker</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#workerglobalscope">WorkerGlobalScope</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#workerlocation">WorkerLocation</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#workernavigator">WorkerNavigator</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#workertype">WorkerType</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#a-browsing-context-is-discarded">a browsing context is discarded</a>
     <li><a href="https://html.spec.whatwg.org/multipage/infrastructure.html#about:blank">about:blank</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url">api base url</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#api-url-character-encoding">api url character encoding</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#application-cache">application cache</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#auxiliary-browsing-context">auxiliary browsing contexts</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#classic-script">classic script</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#creation-url">creation url</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#discard-a-document">discard a document</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source">dom manipulation task source</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-event-type">event handler event type</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-idl-attributes">event handler idl attribute</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers">event handlers</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#event-loop">event loops</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#exceptions-enabled">exceptions enabled flag</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script">fetch a classic worker script</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-module-worker-script-tree">fetch a module worker script tree</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-simple-event">fire a simple event</a>
     <li><a href="https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps">focusing steps</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>
     <li><a href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#https-state">https state</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#import-scripts-into-worker-global-scope">import scripts into worker global scope</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts">importScripts(urls)</a>
     <li><a href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#incumbent-settings-object">incumbent settings object</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-is-top-level">is top-level</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#kill-a-worker">kill a worker</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#list-of-active-timers">list of active timers</a>
     <li><a href="https://html.spec.whatwg.org/multipage/indices.html#event-message">message</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#module-script">module script</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#navigate">navigate</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#nested-browsing-context">nested browsing context</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#parent-browsing-context">parent browsing context</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts-perform-fetch">perform the fetch</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">queue a task</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#realm-execution-context">realm execution context</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-global">relevant global object</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-realm">relevant realm</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant settings object</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#replacement-enabled">replacement enabled</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-browsing-context">responsible browsing context</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document">responsible document</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script">run a classic script</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#run-a-module-script">run a module script</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same origin</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-script">script</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#shared-workers">shared workers</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#source-browsing-context">source browsing context</a>
     <li><a href="https://html.spec.whatwg.org/multipage/infrastructure.html#structuredclonewithtransfer">structuredclonewithtransfer</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queue</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">tasks</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#terminate-a-worker">terminate a worker</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-global-object-realm">the global object's realm</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-realm-global">the realm's global object</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#the-worker&apos;s-documents">the worker's documents</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#top-level-browsing-context">top-level browsing context</a>
     <li><a href="https://html.spec.whatwg.org/multipage/interaction.html#triggered-by-user-activation">triggered by user activation</a>
     <li><a href="https://html.spec.whatwg.org/multipage/infrastructure.html#concept-events-trusted">trusted event</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-type">type</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#unicode-serialisation-of-an-origin">unicode serialization of an origin</a>
     <li><a href="https://html.spec.whatwg.org/multipage/browsers.html#unload-a-document">unload a document</a>
     <li><a href="https://html.spec.whatwg.org/multipage/infrastructure.html#unsafe-response">unsafe response</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-url">url</a>
     <li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#user-interaction-task-source">user interaction task source</a>
     <li><a href="https://html.spec.whatwg.org/multipage/workers.html#workers">web worker</a>
    </ul>
   <li>
    <a data-link-type="biblio">[page-visibility]</a> defines the following terms:
    <ul>
     <li><a href="https://www.w3.org/TR/page-visibility/#VisibilityState">VisibilityState</a>
     <li><a href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a>
    </ul>
   <li>
    <a data-link-type="biblio">[secure-contexts]</a> defines the following terms:
    <ul>
     <li><a href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#is-origin-trustworthy">is origin potentially trustworthy</a>
     <li><a href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#threat-risks">risks associated with insecure contexts</a>
     <li><a href="https://w3c.github.io/webappsec/specs/powerfulfeatures/#secure-context">secure context</a>
    </ul>
   <li>
    <a data-link-type="biblio">[promises-guide]</a> defines the following terms:
    <ul>
     <li><a href="https://www.w3.org/2001/tag/doc/promises-guide#transforming-by">transforming</a>
     <li><a href="https://www.w3.org/2001/tag/doc/promises-guide#waiting-for-all">waiting for all</a>
    </ul>
   <li>
    <a data-link-type="biblio">[quota-api]</a> defines the following terms:
    <ul>
     <li><a href="http://www.w3.org/TR/quota-api/#widl-ServiceWorkerGlobalScope-onbeforeevicted">onbeforeevicted</a>
     <li><a href="http://www.w3.org/TR/quota-api/#widl-ServiceWorkerGlobalScope-onevicted">onevicted</a>
    </ul>
   <li>
    <a data-link-type="biblio">[rfc7230]</a> defines the following terms:
    <ul>
     <li><a href="https://tools.ietf.org/html/rfc7230#section-3.2">field-value</a>
    </ul>
   <li>
    <a data-link-type="biblio">[rfc7231]</a> defines the following terms:
    <ul>
     <li><a href="https://tools.ietf.org/html/rfc7231#section-7.1.4">vary</a>
    </ul>
   <li>
    <a data-link-type="biblio">[WHATWG-URL]</a> defines the following terms:
    <ul>
     <li><a href="https://url.spec.whatwg.org/#concept-url-equals">equals</a>
     <li><a href="https://url.spec.whatwg.org/#is-local">is local</a>
     <li><a href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a>
     <li><a href="https://url.spec.whatwg.org/#concept-url-path">path</a>
     <li><a href="https://url.spec.whatwg.org/#concept-url-query">query</a>
     <li><a href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a>
     <li><a href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a>
     <li><a href="https://url.spec.whatwg.org/#concept-url">url</a>
    </ul>
   <li>
    <a data-link-type="biblio">[WebIDL-1]</a> defines the following terms:
    <ul>
     <li><a href="https://heycam.github.io/webidl/#Exposed">Exposed</a>
     <li><a href="https://heycam.github.io/webidl/#Global">Global</a>
     <li><a href="https://heycam.github.io/webidl/#invalidaccesserror">InvalidAccessError</a>
     <li><a href="https://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a>
     <li><a href="https://heycam.github.io/webidl/#NewObject">NewObject</a>
     <li><a href="https://heycam.github.io/webidl/#quotaexceedederror">QuotaExceededError</a>
     <li><a href="https://heycam.github.io/webidl/#SameObject">SameObject</a>
     <li><a href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>
     <li><a href="https://heycam.github.io/webidl/#securityerror">SecurityError</a>
     <li><a href="https://www.w3.org/TR/WebIDL/#dfn-exception">exception</a>
     <li><a href="https://heycam.github.io/webidl/#dfn-frozen-array-type">frozen array type</a>
     <li><a href="https://www.w3.org/TR/WebIDL/#dfn-partial-interface">partial interface</a>
     <li><a href="https://www.w3.org/TR/WebIDL/#dfn-present">present</a>
     <li><a href="https://heycam.github.io/webidl/#dfn-throw">throw</a>
    </ul>
  </ul>
  <h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2>
  <h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3>
  <dl>
   <dt id="biblio-csp2">[CSP2]
   <dd>Mike West; Adam Barth; Daniel Veditz. <a href="https://www.w3.org/TR/CSP2/">Content Security Policy Level 2</a>. 21 July 2015. CR. URL: <a href="https://www.w3.org/TR/CSP2/">https://www.w3.org/TR/CSP2/</a>
   <dt id="biblio-ecmascript">[ECMASCRIPT]
   <dd><a href="https://tc39.github.io/ecma262/">ECMAScript Language Specification</a>. URL: <a href="https://tc39.github.io/ecma262/">https://tc39.github.io/ecma262/</a>
   <dt id="biblio-fetch">[FETCH]
   <dd>Anne van Kesteren. <a href="https://fetch.spec.whatwg.org/">Fetch Standard</a>. Living Standard. URL: <a href="https://fetch.spec.whatwg.org/">https://fetch.spec.whatwg.org/</a>
   <dt id="biblio-html">[HTML]
   <dd>Ian Hickson. <a href="https://html.spec.whatwg.org/multipage/">HTML Standard</a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a>
   <dt id="biblio-page-visibility">[PAGE-VISIBILITY]
   <dd>Jatinder Mann; Arvind Jain. <a href="https://www.w3.org/TR/page-visibility/">Page Visibility (Second Edition)</a>. 29 October 2013. REC. URL: <a href="https://www.w3.org/TR/page-visibility/">https://www.w3.org/TR/page-visibility/</a>
   <dt id="biblio-promises-guide">[PROMISES-GUIDE]
   <dd><a href="https://www.w3.org/2001/tag/doc/promises-guide">Writing Promise-Using Specifications</a>. 24 July 2015. Finding of the W3C TAG. URL: <a href="https://www.w3.org/2001/tag/doc/promises-guide">https://www.w3.org/2001/tag/doc/promises-guide</a>
   <dt id="biblio-quota-api">[QUOTA-API]
   <dd>Kinuko Yasuda. <a href="https://www.w3.org/TR/quota-api/">Quota Management API</a>. 23 May 2016. NOTE. URL: <a href="https://www.w3.org/TR/quota-api/">https://www.w3.org/TR/quota-api/</a>
   <dt id="biblio-rfc2119">[RFC2119]
   <dd>S. Bradner. <a href="https://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>. March 1997. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc2119">https://tools.ietf.org/html/rfc2119</a>
   <dt id="biblio-rfc5234">[RFC5234]
   <dd>D. Crocker, Ed.; P. Overell. <a href="https://tools.ietf.org/html/rfc5234">Augmented BNF for Syntax Specifications: ABNF</a>. January 2008. Internet Standard. URL: <a href="https://tools.ietf.org/html/rfc5234">https://tools.ietf.org/html/rfc5234</a>
   <dt id="biblio-rfc7230">[RFC7230]
   <dd>R. Fielding, Ed.; J. Reschke, Ed.. <a href="https://tools.ietf.org/html/rfc7230">Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</a>. June 2014. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc7230">https://tools.ietf.org/html/rfc7230</a>
   <dt id="biblio-rfc7231">[RFC7231]
   <dd>R. Fielding, Ed.; J. Reschke, Ed.. <a href="https://tools.ietf.org/html/rfc7231">Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</a>. June 2014. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc7231">https://tools.ietf.org/html/rfc7231</a>
   <dt id="biblio-secure-contexts">[SECURE-CONTEXTS]
   <dd>Mike West. <a href="https://www.w3.org/TR/secure-contexts/">Secure Contexts</a>. 15 September 2016. CR. URL: <a href="https://www.w3.org/TR/secure-contexts/">https://www.w3.org/TR/secure-contexts/</a>
   <dt id="biblio-webidl-1">[WebIDL-1]
   <dd>Cameron McCormack; Boris Zbarsky. <a href="https://www.w3.org/TR/WebIDL-1/">WebIDL Level 1</a>. 15 September 2016. PR. URL: <a href="https://www.w3.org/TR/WebIDL-1/">https://www.w3.org/TR/WebIDL-1/</a>
   <dt id="biblio-whatwg-dom">[WHATWG-DOM]
   <dd>Anne van Kesteren. <a href="https://dom.spec.whatwg.org/">DOM Standard</a>. Living Standard. URL: <a href="https://dom.spec.whatwg.org/">https://dom.spec.whatwg.org/</a>
   <dt id="biblio-whatwg-url">[WHATWG-URL]
   <dd>Anne van Kesteren. <a href="https://url.spec.whatwg.org/">URL Standard</a>. Living Standard. URL: <a href="https://url.spec.whatwg.org/">https://url.spec.whatwg.org/</a>
  </dl>
  <h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3>
  <dl>
   <dt id="biblio-notifications">[NOTIFICATIONS]
   <dd>Anne van Kesteren. <a href="https://notifications.spec.whatwg.org/">Notifications API Standard</a>. Living Standard. URL: <a href="https://notifications.spec.whatwg.org/">https://notifications.spec.whatwg.org/</a>
   <dt id="biblio-unsanctioned-tracking">[UNSANCTIONED-TRACKING]
   <dd><a href="https://www.w3.org/2001/tag/doc/unsanctioned-tracking/">Unsanctioned Web Tracking</a>. 17 July 2015. Finding of the W3C TAG. URL: <a href="https://www.w3.org/2001/tag/doc/unsanctioned-tracking/">https://www.w3.org/2001/tag/doc/unsanctioned-tracking/</a>
  </dl>
  <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">IDL Index</span><a class="self-link" href="#idl-index"></a></h2>
<pre class="idl def">[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-interface">ServiceWorker</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString" href="#service-worker-url-attribute">scriptURL</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-state-enum">ServiceWorkerState</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerState" href="#service-worker-state-attribute">state</a>;
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#service-worker-postmessage-method">postMessage</a>(<span class="kt">any</span> <a class="nv" href="#dom-serviceworker-postmessage-message-transfer-message">message</a>, <span class="kt">optional</span> <span class="kt">sequence</span>&lt;<span class="kt">object</span>> <a class="nv" href="#dom-serviceworker-postmessage-message-transfer-transfer">transfer</a>);

  // event
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-onstatechange-attribute">onstatechange</a>;
};
<a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a> <span class="kt">implements</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#abstractworker">AbstractWorker</a>;

<span class="kt">enum</span> <a class="nv idl-code" data-link-type="enum" href="#service-worker-state-enum">ServiceWorkerState</a> {
  <a class="s" href="#dom-serviceworkerstate-installing">"installing"</a>,
  <a class="s" href="#dom-serviceworkerstate-installed">"installed"</a>,
  <a class="s" href="#dom-serviceworkerstate-activating">"activating"</a>,
  <a class="s" href="#dom-serviceworkerstate-activated">"activated"</a>,
  <a class="s" href="#dom-serviceworkerstate-redundant">"redundant"</a>
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-registration-interface">ServiceWorkerRegistration</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-registration-installing-attribute">installing</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-registration-waiting-attribute">waiting</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-registration-active-attribute">active</a>;

  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString" href="#service-worker-registration-scope-attribute">scope</a>;

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-registration-update-method">update</a>();
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-registration-unregister-method">unregister</a>();

  // event
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-registration-onupdatefound-attribute">onupdatefound</a>;
};

<span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/webappapis.html#navigator">Navigator</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-container-interface">ServiceWorkerContainer</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerContainer" href="#navigator-service-worker-attribute">serviceWorker</a>;
};

<span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/workers.html#workernavigator">WorkerNavigator</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-container-interface">ServiceWorkerContainer</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerContainer" href="#navigator-service-worker-attribute">serviceWorker</a>;
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-container-interface">ServiceWorkerContainer</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorker?" href="#service-worker-container-controller-attribute">controller</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#service-worker-registration-interface">ServiceWorkerRegistration</a>> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Promise<ServiceWorkerRegistration>" href="#service-worker-container-ready-attribute">ready</a>;

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#service-worker-registration-interface">ServiceWorkerRegistration</a>> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-register-method">register</a>(<span class="kt">USVString</span> <a class="nv" href="#dom-serviceworkercontainer-register-scripturl-options-scripturl">scriptURL</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-serviceworkercontainer-registrationoptions">RegistrationOptions</a> <a class="nv" href="#dom-serviceworkercontainer-register-scripturl-options-options">options</a>);

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-getregistration-method">getRegistration</a>(<span class="kt">optional</span> <span class="kt">USVString</span> <a class="nv" href="#dom-serviceworkercontainer-getregistration-clienturl-clienturl">clientURL</a> = "");
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="#service-worker-registration-interface">ServiceWorkerRegistration</a>>> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-getregistrations-method">getRegistrations</a>();

  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#service-worker-container-startMessages-method">startMessages</a>();


  // events
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-container-oncontrollerchange-attribute">oncontrollerchange</a>;
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-container-onmessage-attribute">onmessage</a>; // event.source of message events is ServiceWorker object
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-serviceworkercontainer-registrationoptions">RegistrationOptions</a> {
  <span class="kt">USVString</span> <a class="nv" data-type="USVString " href="#dom-registrationoptions-scope">scope</a>;
  <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#workertype">WorkerType</a> <a class="nv" data-default="&quot;classic&quot;" data-type="WorkerType " href="#dom-registrationoptions-type">type</a> = "classic";
};

[<a class="nv" href="#dom-serviceworkermessageevent-serviceworkermessageevent">Constructor</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-serviceworkermessageevent-serviceworkermessageevent-type-eventinitdict-type">type</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-serviceworkermessageevent-serviceworkermessageeventinit">ServiceWorkerMessageEventInit</a> <a class="nv" href="#dom-serviceworkermessageevent-serviceworkermessageevent-type-eventinitdict-eventinitdict">eventInitDict</a>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#serviceworkermessage-event-interface">ServiceWorkerMessageEvent</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#event">Event</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">any</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="any" href="#serviceworkermessage-event-data-attribute">data</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#serviceworkermessage-event-origin-attribute">origin</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#serviceworkermessage-event-lasteventid-attribute">lastEventId</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> (<a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="(ServiceWorker or MessagePort)?" href="#serviceworkermessage-event-source-attribute">source</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">FrozenArray</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="FrozenArray<MessagePort>?" href="#serviceworkermessage-event-ports-attribute">ports</a>;
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-serviceworkermessageevent-serviceworkermessageeventinit">ServiceWorkerMessageEventInit</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
  <span class="kt">any</span> <a class="nv" data-type="any " href="#dom-serviceworkermessageeventinit-data">data</a>;
  <span class="kt">DOMString</span> <a class="nv" data-type="DOMString " href="#dom-serviceworkermessageeventinit-origin">origin</a>;
  <span class="kt">DOMString</span> <a class="nv" data-type="DOMString " href="#dom-serviceworkermessageeventinit-lasteventid">lastEventId</a>;
  (<a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <a class="nv" data-type="(ServiceWorker or MessagePort)? " href="#dom-serviceworkermessageeventinit-source">source</a>;
  <span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <a class="nv" data-type="sequence<MessagePort>? " href="#dom-serviceworkermessageeventinit-ports">ports</a>;
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Global">Global</a>=(<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#worker">Worker</a>,<a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#service-worker-global-scope-interface">ServiceWorkerGlobalScope</a> : <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/workers.html#workerglobalscope">WorkerGlobalScope</a> {
  // A container for a list of Client objects that correspond to
  // browsing contexts (or shared workers) that are on the origin of this SW
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#clients-interface">Clients</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Clients" href="#service-worker-global-scope-clients-attribute">clients</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#service-worker-registration-interface">ServiceWorkerRegistration</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="ServiceWorkerRegistration" href="#service-worker-global-scope-scope-attribute">registration</a>;

  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#service-worker-global-scope-skipwaiting-method">skipWaiting</a>();

  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-oninstall-attribute">oninstall</a>;
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-onactivate-attribute">onactivate</a>;
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-onfetch-attribute">onfetch</a>;

  // event
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/webappapis.html#eventhandler">EventHandler</a> <a class="nv idl-code" data-link-type="attribute" data-type="EventHandler" href="#service-worker-global-scope-onmessage-attribute">onmessage</a>; // event.source of the message events is Client object
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#client-interface">Client</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString" href="#client-url-attribute">url</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#contextframetype-enum">FrameType</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="FrameType" href="#client-frametype-attribute">frameType</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#client-id-attribute">id</a>;
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#client-postmessage-method">postMessage</a>(<span class="kt">any</span> <a class="nv" href="#dom-client-postmessage-message-transfer-message">message</a>, <span class="kt">optional</span> <span class="kt">sequence</span>&lt;<span class="kt">object</span>> <a class="nv" href="#dom-client-postmessage-message-transfer-transfer">transfer</a>);
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#window-client-interface">WindowClient</a> : <a class="n" data-link-type="idl-name" href="#client-interface">Client</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/page-visibility/#VisibilityState">VisibilityState</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="VisibilityState" href="#client-visibilitystate-attribute">visibilityState</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="#client-focused-attribute">focused</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#window-client-interface">WindowClient</a>> <a class="nv idl-code" data-link-type="method" href="#client-focus-method">focus</a>();
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#window-client-interface">WindowClient</a>> <a class="nv idl-code" data-link-type="method" href="#client-navigate-method">navigate</a>(<span class="kt">USVString</span> <a class="nv" href="#dom-windowclient-navigate-url-url">url</a>);
};

<span class="kt">enum</span> <a class="nv idl-code" data-link-type="enum" href="#contextframetype-enum">FrameType</a> {
  <a class="s" href="#dom-frametype-auxiliary">"auxiliary"</a>,
  <a class="s" href="#dom-frametype-top-level">"top-level"</a>,
  <a class="s" href="#dom-frametype-nested">"nested"</a>,
  <a class="s" href="#dom-frametype-none">"none"</a>
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#clients-interface">Clients</a> {
  // The objects returned will be new instances every time
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#clients-get-method">get</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-clients-get-id-id">id</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="#client-interface">Client</a>>> <a class="nv idl-code" data-link-type="method" href="#clients-matchall-method">matchAll</a>(<span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-clients-clientqueryoptions">ClientQueryOptions</a> <a class="nv" href="#dom-clients-matchall-options-options">options</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#window-client-interface">WindowClient</a>?> <a class="nv idl-code" data-link-type="method" href="#clients-openwindow-method">openWindow</a>(<span class="kt">USVString</span> <a class="nv" href="#dom-clients-openwindow-url-url">url</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#clients-claim-method">claim</a>();
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-clients-clientqueryoptions">ClientQueryOptions</a> {
  <span class="kt">boolean</span> <a class="nv" data-default="false" data-type="boolean " href="#dom-clientqueryoptions-includeuncontrolled">includeUncontrolled</a> = <span class="kt">false</span>;
  <a class="n" data-link-type="idl-name" href="#enumdef-clients-clienttype">ClientType</a> <a class="nv" data-default="&quot;window&quot;" data-type="ClientType " href="#dom-clientqueryoptions-type">type</a> = "window";
};

<span class="kt">enum</span> <a class="nv" href="#enumdef-clients-clienttype">ClientType</a> {
  <a class="s" href="#dom-clienttype-window">"window"</a>,
  <a class="s" href="#dom-clienttype-worker">"worker"</a>,
  <a class="s" href="#dom-clienttype-sharedworker">"sharedworker"</a>,
  <a class="s" href="#dom-clienttype-all">"all"</a>
};

[<a class="nv" href="#dom-extendableevent-extendableevent">Constructor</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-extendableevent-extendableevent-type-eventinitdict-type">type</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-extendableeventinit">ExtendableEventInit</a> <a class="nv" href="#dom-extendableevent-extendableevent-type-eventinitdict-eventinitdict">eventInitDict</a>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#extendable-event-interface">ExtendableEvent</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#event">Event</a> {
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#extendable-event-waituntil-method">waitUntil</a>(<span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv" href="#dom-extendableevent-waituntil-f-f">f</a>);
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-extendableeventinit">ExtendableEventInit</a> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
  // Defined for the forward compatibility across the derived events
};

[<a class="nv" href="#dom-fetchevent-fetchevent">Constructor</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-fetchevent-fetchevent-type-eventinitdict-type">type</a>, <a class="n" data-link-type="idl-name" href="#dictdef-fetchevent-fetcheventinit">FetchEventInit</a> <a class="nv" href="#dom-fetchevent-fetchevent-type-eventinitdict-eventinitdict">eventInitDict</a>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#fetch-event-interface">FetchEvent</a> : <a class="n" data-link-type="idl-name" href="#extendable-event-interface">ExtendableEvent</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Request" href="#fetch-event-request-attribute">request</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString?" href="#fetch-event-clientid-attribute">clientId</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="#fetch-event-isreload-attribute">isReload</a>;

  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="#fetch-event-respondwith-method">respondWith</a>(<span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a>> <a class="nv" href="#dom-fetchevent-respondwith-r-r">r</a>);
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-fetchevent-fetcheventinit">FetchEventInit</a> : <a class="n" data-link-type="idl-name" href="#dictdef-extendableeventinit">ExtendableEventInit</a> {
  <span class="kt">required</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a> <a class="nv" data-type="Request " href="#dom-fetcheventinit-request">request</a>;
  <span class="kt">DOMString</span>? <a class="nv" data-default="null" data-type="DOMString? " href="#dom-fetcheventinit-clientid">clientId</a> = <span class="kt">null</span>;
  <span class="kt">boolean</span> <a class="nv" data-default="false" data-type="boolean " href="#dom-fetcheventinit-isreload">isReload</a> = <span class="kt">false</span>;
};

[<a class="nv" href="#dom-extendablemessageevent-extendablemessageevent">Constructor</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-extendablemessageevent-extendablemessageevent-type-eventinitdict-type">type</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-extendablemessageevent-extendablemessageeventinit">ExtendableMessageEventInit</a> <a class="nv" href="#dom-extendablemessageevent-extendablemessageevent-type-eventinitdict-eventinitdict">eventInitDict</a>), <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<span class="n">ServiceWorker</span>]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#extendablemessage-event-interface">ExtendableMessageEvent</a> : <a class="n" data-link-type="idl-name" href="#extendable-event-interface">ExtendableEvent</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">any</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="any" href="#extendablemessage-event-data-attribute">data</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#extendablemessage-event-origin-attribute">origin</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="#extendablemessage-event-lasteventid-attribute">lastEventId</a>;
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> (<a class="n" data-link-type="idl-name" href="#client-interface">Client</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="(Client or ServiceWorker or MessagePort)?" href="#extendablemessage-event-source-attribute">source</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">FrozenArray</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="FrozenArray<MessagePort>?" href="#extendablemessage-event-ports-attribute">ports</a>;
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-extendablemessageevent-extendablemessageeventinit">ExtendableMessageEventInit</a> : <a class="n" data-link-type="idl-name" href="#dictdef-extendableeventinit">ExtendableEventInit</a> {
  <span class="kt">any</span> <a class="nv" data-type="any " href="#dom-extendablemessageeventinit-data">data</a>;
  <span class="kt">DOMString</span> <a class="nv" data-type="DOMString " href="#dom-extendablemessageeventinit-origin">origin</a>;
  <span class="kt">DOMString</span> <a class="nv" data-type="DOMString " href="#dom-extendablemessageeventinit-lasteventid">lastEventId</a>;
  (<a class="n" data-link-type="idl-name" href="#client-interface">Client</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="#service-worker-interface">ServiceWorker</a> <span class="kt">or</span> <a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>)? <a class="nv" data-type="(Client or ServiceWorker or MessagePort)? " href="#dom-extendablemessageeventinit-source">source</a>;
  <span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://html.spec.whatwg.org/multipage/comms.html#messageport">MessagePort</a>>? <a class="nv" data-type="sequence<MessagePort>? " href="#dom-extendablemessageeventinit-ports">ports</a>;
};

<span class="kt">partial</span> <span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope">WindowOrWorkerGlobalScope</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="#cache-storage-interface">CacheStorage</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="CacheStorage" href="#global-caches-attribute">caches</a>;
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#cache-interface">Cache</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#cache-match-method">match</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <a class="nv" href="#dom-cache-match-request-options-request">request</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a> <a class="nv" href="#dom-cache-match-request-options-options">options</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a>>> <a class="nv idl-code" data-link-type="method" href="#cache-matchall-method">matchAll</a>(<span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <a class="nv" href="#dom-cache-matchall-request-options-request">request</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a> <a class="nv" href="#dom-cache-matchall-request-options-options">options</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#cache-add-method">add</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <a class="nv" href="#dom-cache-add-request-request">request</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#cache-addAll-method">addAll</a>(<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a>> <a class="nv" href="#dom-cache-addall-requests-requests">requests</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">void</span>> <a class="nv idl-code" data-link-type="method" href="#cache-put-method">put</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <a class="nv" href="#dom-cache-put-request-response-request">request</a>, <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a> <a class="nv" href="#dom-cache-put-request-response-response">response</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#cache-delete-method">delete</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <a class="nv" href="#dom-cache-delete-request-options-request">request</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a> <a class="nv" href="#dom-cache-delete-request-options-options">options</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a>>> <a class="nv idl-code" data-link-type="method" href="#cache-keys-method">keys</a>(<span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <a class="nv" href="#dom-cache-keys-request-options-request">request</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a> <a class="nv" href="#dom-cache-keys-request-options-options">options</a>);
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a> {
  <span class="kt">boolean</span> <a class="nv" data-default="false" data-type="boolean " href="#dom-cachequeryoptions-ignoresearch">ignoreSearch</a> = <span class="kt">false</span>;
  <span class="kt">boolean</span> <a class="nv" data-default="false" data-type="boolean " href="#dom-cachequeryoptions-ignoremethod">ignoreMethod</a> = <span class="kt">false</span>;
  <span class="kt">boolean</span> <a class="nv" data-default="false" data-type="boolean " href="#dom-cachequeryoptions-ignorevary">ignoreVary</a> = <span class="kt">false</span>;
  <span class="kt">DOMString</span> <a class="nv" data-type="DOMString " href="#dom-cachequeryoptions-cachename">cacheName</a>;
};

<span class="kt">dictionary</span> <a class="nv" href="#dictdef-cache-cachebatchoperation">CacheBatchOperation</a> {
  <span class="kt">DOMString</span> <a class="nv" data-type="DOMString " href="#dom-cachebatchoperation-type">type</a>;
  <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#request">Request</a> <a class="nv" data-type="Request " href="#dom-cachebatchoperation-request">request</a>;
  <a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#response">Response</a> <a class="nv" data-type="Response " href="#dom-cachebatchoperation-response">response</a>;
  <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a> <a class="nv" data-type="CacheQueryOptions " href="#dom-cachebatchoperation-options">options</a>;
};

[<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SecureContext">SecureContext</a>, <a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <a class="nv idl-code" data-link-type="interface" href="#cache-storage-interface">CacheStorage</a> {
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">any</span>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-match-method">match</a>(<a class="n" data-link-type="idl-name" href="https://fetch.spec.whatwg.org/#requestinfo">RequestInfo</a> <a class="nv" href="#dom-cachestorage-match-request-options-request">request</a>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="#dictdef-cache-cachequeryoptions">CacheQueryOptions</a> <a class="nv" href="#dom-cachestorage-match-request-options-options">options</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-has-method">has</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-cachestorage-has-cachename-cachename">cacheName</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<a class="n" data-link-type="idl-name" href="#cache-interface">Cache</a>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-open-method">open</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-cachestorage-open-cachename-cachename">cacheName</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">boolean</span>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-delete-method">delete</a>(<span class="kt">DOMString</span> <a class="nv" href="#dom-cachestorage-delete-cachename-cachename">cacheName</a>);
  [<a class="nv idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject">NewObject</a>] <span class="kt">Promise</span>&lt;<span class="kt">sequence</span>&lt;<span class="kt">DOMString</span>>> <a class="nv idl-code" data-link-type="method" href="#cache-storage-keys-method">keys</a>();
};

</pre>
  <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content">Issues Index</span><a class="self-link" href="#issues-index"></a></h2>
  <div style="counter-reset:issue">
   <div class="issue">The response’s cache state concept had been removed from fetch. The fetch issue <a href="https://github.com/whatwg/fetch/issues/376">#376</a> tracks the request to restore the concept or add some similar way to check this state.<a href="#issue-3c7457a0"> ↵ </a></div>
   <div class="issue">Remove this definition after sorting out the referencing sites.<a href="#issue-b739bfcf"> ↵ </a></div>
  </div>
  <aside class="dfn-panel" data-for="dfn-service-worker">
   <b><a href="#dfn-service-worker">#dfn-service-worker</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-1">1. Motivations</a> <a href="#ref-for-dfn-service-worker-2">(2)</a> <a href="#ref-for-dfn-service-worker-3">(3)</a> <a href="#ref-for-dfn-service-worker-4">(4)</a> <a href="#ref-for-dfn-service-worker-5">(5)</a> <a href="#ref-for-dfn-service-worker-6">(6)</a> <a href="#ref-for-dfn-service-worker-7">(7)</a> <a href="#ref-for-dfn-service-worker-8">(8)</a> <a href="#ref-for-dfn-service-worker-9">(9)</a> <a href="#ref-for-dfn-service-worker-10">(10)</a> <a href="#ref-for-dfn-service-worker-11">(11)</a> <a href="#ref-for-dfn-service-worker-12">(12)</a> <a href="#ref-for-dfn-service-worker-13">(13)</a> <a href="#ref-for-dfn-service-worker-14">(14)</a>
    <li><a href="#ref-for-dfn-service-worker-15">2.1. Service Worker</a> <a href="#ref-for-dfn-service-worker-16">(2)</a> <a href="#ref-for-dfn-service-worker-17">(3)</a> <a href="#ref-for-dfn-service-worker-18">(4)</a> <a href="#ref-for-dfn-service-worker-19">(5)</a> <a href="#ref-for-dfn-service-worker-20">(6)</a> <a href="#ref-for-dfn-service-worker-21">(7)</a> <a href="#ref-for-dfn-service-worker-22">(8)</a> <a href="#ref-for-dfn-service-worker-23">(9)</a> <a href="#ref-for-dfn-service-worker-24">(10)</a> <a href="#ref-for-dfn-service-worker-25">(11)</a> <a href="#ref-for-dfn-service-worker-26">(12)</a>
    <li><a href="#ref-for-dfn-service-worker-27">2.1.1. Lifetime</a> <a href="#ref-for-dfn-service-worker-28">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-29">2.2. Service Worker Registration</a> <a href="#ref-for-dfn-service-worker-30">(2)</a> <a href="#ref-for-dfn-service-worker-31">(3)</a> <a href="#ref-for-dfn-service-worker-32">(4)</a>
    <li><a href="#ref-for-dfn-service-worker-33">2.5. Task Sources</a> <a href="#ref-for-dfn-service-worker-34">(2)</a> <a href="#ref-for-dfn-service-worker-35">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-36">2.6. User Agent Shutdown</a>
    <li><a href="#ref-for-dfn-service-worker-37">3.1. ServiceWorker</a> <a href="#ref-for-dfn-service-worker-38">(2)</a> <a href="#ref-for-dfn-service-worker-39">(3)</a> <a href="#ref-for-dfn-service-worker-40">(4)</a>
    <li><a href="#ref-for-dfn-service-worker-41">3.1.1. scriptURL</a>
    <li><a href="#ref-for-dfn-service-worker-42">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-dfn-service-worker-43">3.2.1. installing</a>
    <li><a href="#ref-for-dfn-service-worker-44">3.2.2. waiting</a>
    <li><a href="#ref-for-dfn-service-worker-45">3.2.3. active</a>
    <li><a href="#ref-for-dfn-service-worker-46">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-dfn-service-worker-47">3.4.1. controller</a>
    <li><a href="#ref-for-dfn-service-worker-48">3.5. ServiceWorkerMessageEvent</a> <a href="#ref-for-dfn-service-worker-49">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-50">3.5.2. event.origin</a>
    <li><a href="#ref-for-dfn-service-worker-51">3.5.4. event.source</a>
    <li><a href="#ref-for-dfn-service-worker-52">3.6. Events</a> <a href="#ref-for-dfn-service-worker-53">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-54">4.1. ServiceWorkerGlobalScope</a> <a href="#ref-for-dfn-service-worker-55">(2)</a> <a href="#ref-for-dfn-service-worker-56">(3)</a> <a href="#ref-for-dfn-service-worker-57">(4)</a>
    <li><a href="#ref-for-dfn-service-worker-58">4.1.3. skipWaiting()</a> <a href="#ref-for-dfn-service-worker-59">(2)</a> <a href="#ref-for-dfn-service-worker-60">(3)</a> <a href="#ref-for-dfn-service-worker-61">(4)</a>
    <li><a href="#ref-for-dfn-service-worker-62">4.4. ExtendableEvent</a> <a href="#ref-for-dfn-service-worker-63">(2)</a> <a href="#ref-for-dfn-service-worker-64">(3)</a> <a href="#ref-for-dfn-service-worker-65">(4)</a> <a href="#ref-for-dfn-service-worker-66">(5)</a> <a href="#ref-for-dfn-service-worker-67">(6)</a> <a href="#ref-for-dfn-service-worker-68">(7)</a>
    <li><a href="#ref-for-dfn-service-worker-69">4.5. FetchEvent</a> <a href="#ref-for-dfn-service-worker-70">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-71">4.6. ExtendableMessageEvent</a> <a href="#ref-for-dfn-service-worker-72">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-73">5.2. Understanding Cache Lifetimes</a> <a href="#ref-for-dfn-service-worker-74">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-75">6.1. Secure Context</a> <a href="#ref-for-dfn-service-worker-76">(2)</a> <a href="#ref-for-dfn-service-worker-77">(3)</a> <a href="#ref-for-dfn-service-worker-78">(4)</a> <a href="#ref-for-dfn-service-worker-79">(5)</a>
    <li><a href="#ref-for-dfn-service-worker-80">6.2. Content Security Policy</a>
    <li><a href="#ref-for-dfn-service-worker-81">6.3.1. Origin restriction</a> <a href="#ref-for-dfn-service-worker-82">(2)</a> <a href="#ref-for-dfn-service-worker-83">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-84">6.4. Cross-Origin Resources and CORS</a>
    <li><a href="#ref-for-dfn-service-worker-85">6.5. Implementer Concerns</a> <a href="#ref-for-dfn-service-worker-86">(2)</a> <a href="#ref-for-dfn-service-worker-87">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-88">6.6. Privacy</a> <a href="#ref-for-dfn-service-worker-89">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-90">7. Storage Considerations</a> <a href="#ref-for-dfn-service-worker-91">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-92">8. Extensibility</a>
    <li><a href="#ref-for-dfn-service-worker-93">8.4. Request Functional Event Dispatch</a>
    <li><a href="#ref-for-dfn-service-worker-94">Update</a>
    <li><a href="#ref-for-dfn-service-worker-95">Install</a> <a href="#ref-for-dfn-service-worker-96">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-97">Run Service Worker</a>
    <li><a href="#ref-for-dfn-service-worker-98">Terminate Service Worker</a>
    <li><a href="#ref-for-dfn-service-worker-99">Handle Fetch</a>
    <li><a href="#ref-for-dfn-service-worker-100">Update Registration State</a>
    <li><a href="#ref-for-dfn-service-worker-101">Update Worker State</a> <a href="#ref-for-dfn-service-worker-102">(2)</a> <a href="#ref-for-dfn-service-worker-103">(3)</a> <a href="#ref-for-dfn-service-worker-104">(4)</a> <a href="#ref-for-dfn-service-worker-105">(5)</a> <a href="#ref-for-dfn-service-worker-106">(6)</a> <a href="#ref-for-dfn-service-worker-107">(7)</a> <a href="#ref-for-dfn-service-worker-108">(8)</a> <a href="#ref-for-dfn-service-worker-109">(9)</a> <a href="#ref-for-dfn-service-worker-110">(10)</a>
    <li><a href="#ref-for-dfn-service-worker-111">Get Newest Worker</a>
    <li><a href="#ref-for-dfn-service-worker-112">Service Worker Script Request</a> <a href="#ref-for-dfn-service-worker-113">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-114">Service Worker Script Response</a>
    <li><a href="#ref-for-dfn-service-worker-115">Syntax</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-state">
   <b><a href="#dfn-state">#dfn-state</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-state-1">2.2. Service Worker Registration</a> <a href="#ref-for-dfn-state-2">(2)</a> <a href="#ref-for-dfn-state-3">(3)</a>
    <li><a href="#ref-for-dfn-state-4">3.1. ServiceWorker</a>
    <li><a href="#ref-for-dfn-state-5">3.2.5. update()</a>
    <li><a href="#ref-for-dfn-state-6">4.1.3. skipWaiting()</a>
    <li><a href="#ref-for-dfn-state-7">4.4. ExtendableEvent</a> <a href="#ref-for-dfn-state-8">(2)</a> <a href="#ref-for-dfn-state-9">(3)</a>
    <li><a href="#ref-for-dfn-state-10">Handle Fetch</a> <a href="#ref-for-dfn-state-11">(2)</a>
    <li><a href="#ref-for-dfn-state-12">Handle Functional Event</a> <a href="#ref-for-dfn-state-13">(2)</a>
    <li><a href="#ref-for-dfn-state-14">Update Worker State</a> <a href="#ref-for-dfn-state-15">(2)</a> <a href="#ref-for-dfn-state-16">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-script-url">
   <b><a href="#dfn-script-url">#dfn-script-url</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-script-url-1">3.1.1. scriptURL</a>
    <li><a href="#ref-for-dfn-script-url-2">3.2.5. update()</a>
    <li><a href="#ref-for-dfn-script-url-3">Register</a>
    <li><a href="#ref-for-dfn-script-url-4">Update</a> <a href="#ref-for-dfn-script-url-5">(2)</a> <a href="#ref-for-dfn-script-url-6">(3)</a>
    <li><a href="#ref-for-dfn-script-url-7">Soft Update</a>
    <li><a href="#ref-for-dfn-script-url-8">Run Service Worker</a> <a href="#ref-for-dfn-script-url-9">(2)</a> <a href="#ref-for-dfn-script-url-10">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-type">
   <b><a href="#dfn-type">#dfn-type</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-type-1">3.2.5. update()</a>
    <li><a href="#ref-for-dfn-type-2">Update</a>
    <li><a href="#ref-for-dfn-type-3">Soft Update</a>
    <li><a href="#ref-for-dfn-type-4">Run Service Worker</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-containing-service-worker-registration">
   <b><a href="#dfn-containing-service-worker-registration">#dfn-containing-service-worker-registration</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-1">2.1. Service Worker</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-2">2.4. Selection and Use</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-3">3.2.6. unregister()</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-4">4.1.2. registration</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-5">4.1.3. skipWaiting()</a> <a href="#ref-for-dfn-containing-service-worker-registration-6">(2)</a> <a href="#ref-for-dfn-containing-service-worker-registration-7">(3)</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-8">4.3.4. claim()</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-9">4.7. Events</a> <a href="#ref-for-dfn-containing-service-worker-registration-10">(2)</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-11">Install</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-12">Run Service Worker</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-13">Terminate Service Worker</a>
    <li><a href="#ref-for-dfn-containing-service-worker-registration-14">Handle Fetch</a> <a href="#ref-for-dfn-containing-service-worker-registration-15">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-id">
   <b><a href="#dfn-service-worker-id">#dfn-service-worker-id</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-id-1">Update</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-lifecycle-events">
   <b><a href="#dfn-lifecycle-events">#dfn-lifecycle-events</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-lifecycle-events-1">4.4. ExtendableEvent</a>
    <li><a href="#ref-for-dfn-lifecycle-events-2">4.7. Events</a> <a href="#ref-for-dfn-lifecycle-events-3">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-functional-events">
   <b><a href="#dfn-functional-events">#dfn-functional-events</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-functional-events-1">2.5. Task Sources</a>
    <li><a href="#ref-for-dfn-functional-events-2">4.4. ExtendableEvent</a>
    <li><a href="#ref-for-dfn-functional-events-3">4.5. FetchEvent</a>
    <li><a href="#ref-for-dfn-functional-events-4">4.7. Events</a>
    <li><a href="#ref-for-dfn-functional-events-5">8.2. Define Functional Event</a>
    <li><a href="#ref-for-dfn-functional-events-6">8.3. Define Event Handler</a>
    <li><a href="#ref-for-dfn-functional-events-7">8.4. Request Functional Event Dispatch</a> <a href="#ref-for-dfn-functional-events-8">(2)</a> <a href="#ref-for-dfn-functional-events-9">(3)</a>
    <li><a href="#ref-for-dfn-functional-events-10">Update Worker State</a> <a href="#ref-for-dfn-functional-events-11">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-script-resource">
   <b><a href="#dfn-script-resource">#dfn-script-resource</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-script-resource-1">2.1. Service Worker</a> <a href="#ref-for-dfn-script-resource-2">(2)</a>
    <li><a href="#ref-for-dfn-script-resource-3">6.2. Content Security Policy</a> <a href="#ref-for-dfn-script-resource-4">(2)</a>
    <li><a href="#ref-for-dfn-script-resource-5">Update</a> <a href="#ref-for-dfn-script-resource-6">(2)</a>
    <li><a href="#ref-for-dfn-script-resource-7">Run Service Worker</a> <a href="#ref-for-dfn-script-resource-8">(2)</a>
    <li><a href="#ref-for-dfn-script-resource-9">Service Worker Script Request</a> <a href="#ref-for-dfn-script-resource-10">(2)</a>
    <li><a href="#ref-for-dfn-script-resource-11">Service Worker Script Response</a>
    <li><a href="#ref-for-dfn-script-resource-12">Syntax</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-has-ever-been-evaluated-flag">
   <b><a href="#dfn-has-ever-been-evaluated-flag">#dfn-has-ever-been-evaluated-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-has-ever-been-evaluated-flag-1">Run Service Worker</a> <a href="#ref-for-dfn-has-ever-been-evaluated-flag-2">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-https-state">
   <b><a href="#dfn-https-state">#dfn-https-state</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-https-state-1">Run Service Worker</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-script-resource-map">
   <b><a href="#dfn-script-resource-map">#dfn-script-resource-map</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-script-resource-map-1">6.3.2. importScripts(urls)</a> <a href="#ref-for-dfn-script-resource-map-2">(2)</a> <a href="#ref-for-dfn-script-resource-map-3">(3)</a>
    <li><a href="#ref-for-dfn-script-resource-map-4">6.6. Privacy</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-skip-waiting-flag">
   <b><a href="#dfn-skip-waiting-flag">#dfn-skip-waiting-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-skip-waiting-flag-1">3.6. Events</a>
    <li><a href="#ref-for-dfn-skip-waiting-flag-2">4.1.3. skipWaiting()</a>
    <li><a href="#ref-for-dfn-skip-waiting-flag-3">Install</a> <a href="#ref-for-dfn-skip-waiting-flag-4">(2)</a> <a href="#ref-for-dfn-skip-waiting-flag-5">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-imported-scripts-updated-flag">
   <b><a href="#dfn-imported-scripts-updated-flag">#dfn-imported-scripts-updated-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-imported-scripts-updated-flag-1">6.3.2. importScripts(urls)</a>
    <li><a href="#ref-for-dfn-imported-scripts-updated-flag-2">Install</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-set-of-event-types-to-handle">
   <b><a href="#dfn-set-of-event-types-to-handle">#dfn-set-of-event-types-to-handle</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-set-of-event-types-to-handle-1">Run Service Worker</a>
    <li><a href="#ref-for-dfn-set-of-event-types-to-handle-2">Handle Fetch</a>
    <li><a href="#ref-for-dfn-set-of-event-types-to-handle-3">Handle Functional Event</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-registration">
   <b><a href="#dfn-service-worker-registration">#dfn-service-worker-registration</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-registration-1">2.1. Service Worker</a>
    <li><a href="#ref-for-dfn-service-worker-registration-2">2.2. Service Worker Registration</a> <a href="#ref-for-dfn-service-worker-registration-3">(2)</a> <a href="#ref-for-dfn-service-worker-registration-4">(3)</a> <a href="#ref-for-dfn-service-worker-registration-5">(4)</a> <a href="#ref-for-dfn-service-worker-registration-6">(5)</a> <a href="#ref-for-dfn-service-worker-registration-7">(6)</a> <a href="#ref-for-dfn-service-worker-registration-8">(7)</a> <a href="#ref-for-dfn-service-worker-registration-9">(8)</a> <a href="#ref-for-dfn-service-worker-registration-10">(9)</a> <a href="#ref-for-dfn-service-worker-registration-11">(10)</a> <a href="#ref-for-dfn-service-worker-registration-12">(11)</a> <a href="#ref-for-dfn-service-worker-registration-13">(12)</a> <a href="#ref-for-dfn-service-worker-registration-14">(13)</a> <a href="#ref-for-dfn-service-worker-registration-15">(14)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-16">2.2.1. Lifetime</a> <a href="#ref-for-dfn-service-worker-registration-17">(2)</a> <a href="#ref-for-dfn-service-worker-registration-18">(3)</a> <a href="#ref-for-dfn-service-worker-registration-19">(4)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-20">2.4. Selection and Use</a> <a href="#ref-for-dfn-service-worker-registration-21">(2)</a> <a href="#ref-for-dfn-service-worker-registration-22">(3)</a> <a href="#ref-for-dfn-service-worker-registration-23">(4)</a> <a href="#ref-for-dfn-service-worker-registration-24">(5)</a> <a href="#ref-for-dfn-service-worker-registration-25">(6)</a> <a href="#ref-for-dfn-service-worker-registration-26">(7)</a> <a href="#ref-for-dfn-service-worker-registration-27">(8)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-28">2.6. User Agent Shutdown</a> <a href="#ref-for-dfn-service-worker-registration-29">(2)</a> <a href="#ref-for-dfn-service-worker-registration-30">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-31">3.2. ServiceWorkerRegistration</a> <a href="#ref-for-dfn-service-worker-registration-32">(2)</a> <a href="#ref-for-dfn-service-worker-registration-33">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-34">3.2.6. unregister()</a> <a href="#ref-for-dfn-service-worker-registration-35">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-36">3.4. ServiceWorkerContainer</a> <a href="#ref-for-dfn-service-worker-registration-37">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-38">3.4.2. ready</a>
    <li><a href="#ref-for-dfn-service-worker-registration-39">3.4.3. register(scriptURL, options)</a> <a href="#ref-for-dfn-service-worker-registration-40">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-41">3.6. Events</a> <a href="#ref-for-dfn-service-worker-registration-42">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-43">6.1. Secure Context</a> <a href="#ref-for-dfn-service-worker-registration-44">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-45">6.6. Privacy</a>
    <li><a href="#ref-for-dfn-service-worker-registration-46">8.1. Define API bound to Service Worker Registration</a>
    <li><a href="#ref-for-dfn-service-worker-registration-47">8.4. Request Functional Event Dispatch</a>
    <li><a href="#ref-for-dfn-service-worker-registration-48">Appendix A: Algorithms</a> <a href="#ref-for-dfn-service-worker-registration-49">(2)</a> <a href="#ref-for-dfn-service-worker-registration-50">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-51">Soft Update</a>
    <li><a href="#ref-for-dfn-service-worker-registration-52">Install</a>
    <li><a href="#ref-for-dfn-service-worker-registration-53">Activate</a>
    <li><a href="#ref-for-dfn-service-worker-registration-54">Handle Functional Event</a>
    <li><a href="#ref-for-dfn-service-worker-registration-55">Handle Service Worker Client Unload</a>
    <li><a href="#ref-for-dfn-service-worker-registration-56">Set Registration</a> <a href="#ref-for-dfn-service-worker-registration-57">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-58">Clear Registration</a>
    <li><a href="#ref-for-dfn-service-worker-registration-59">Update Registration State</a>
    <li><a href="#ref-for-dfn-service-worker-registration-60">Match Service Worker Registration</a>
    <li><a href="#ref-for-dfn-service-worker-registration-61">Get Registration</a>
    <li><a href="#ref-for-dfn-service-worker-registration-62">Get Newest Worker</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-scope-url">
   <b><a href="#dfn-scope-url">#dfn-scope-url</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-scope-url-1">2.2. Service Worker Registration</a> <a href="#ref-for-dfn-scope-url-2">(2)</a> <a href="#ref-for-dfn-scope-url-3">(3)</a>
    <li><a href="#ref-for-dfn-scope-url-4">2.2.1. Lifetime</a>
    <li><a href="#ref-for-dfn-scope-url-5">2.4. Selection and Use</a>
    <li><a href="#ref-for-dfn-scope-url-6">3.2.4. scope</a>
    <li><a href="#ref-for-dfn-scope-url-7">3.2.5. update()</a>
    <li><a href="#ref-for-dfn-scope-url-8">3.2.6. unregister()</a>
    <li><a href="#ref-for-dfn-scope-url-9">3.4.3. register(scriptURL, options)</a> <a href="#ref-for-dfn-scope-url-10">(2)</a>
    <li><a href="#ref-for-dfn-scope-url-11">Appendix A: Algorithms</a> <a href="#ref-for-dfn-scope-url-12">(2)</a>
    <li><a href="#ref-for-dfn-scope-url-13">Update</a>
    <li><a href="#ref-for-dfn-scope-url-14">Soft Update</a>
    <li><a href="#ref-for-dfn-scope-url-15">Install</a>
    <li><a href="#ref-for-dfn-scope-url-16">Activate</a>
    <li><a href="#ref-for-dfn-scope-url-17">Set Registration</a>
    <li><a href="#ref-for-dfn-scope-url-18">Clear Registration</a>
    <li><a href="#ref-for-dfn-scope-url-19">Service Worker Script Response</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-installing-worker">
   <b><a href="#dfn-installing-worker">#dfn-installing-worker</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-installing-worker-1">2.2. Service Worker Registration</a>
    <li><a href="#ref-for-dfn-installing-worker-2">2.6. User Agent Shutdown</a> <a href="#ref-for-dfn-installing-worker-3">(2)</a>
    <li><a href="#ref-for-dfn-installing-worker-4">3.6. Events</a>
    <li><a href="#ref-for-dfn-installing-worker-5">4.4. ExtendableEvent</a>
    <li><a href="#ref-for-dfn-installing-worker-6">4.7. Events</a>
    <li><a href="#ref-for-dfn-installing-worker-7">Install</a> <a href="#ref-for-dfn-installing-worker-8">(2)</a> <a href="#ref-for-dfn-installing-worker-9">(3)</a> <a href="#ref-for-dfn-installing-worker-10">(4)</a> <a href="#ref-for-dfn-installing-worker-11">(5)</a>
    <li><a href="#ref-for-dfn-installing-worker-12">Handle User Agent Shutdown</a> <a href="#ref-for-dfn-installing-worker-13">(2)</a>
    <li><a href="#ref-for-dfn-installing-worker-14">Clear Registration</a> <a href="#ref-for-dfn-installing-worker-15">(2)</a>
    <li><a href="#ref-for-dfn-installing-worker-16">Update Registration State</a> <a href="#ref-for-dfn-installing-worker-17">(2)</a> <a href="#ref-for-dfn-installing-worker-18">(3)</a>
    <li><a href="#ref-for-dfn-installing-worker-19">Update Worker State</a> <a href="#ref-for-dfn-installing-worker-20">(2)</a>
    <li><a href="#ref-for-dfn-installing-worker-21">Get Newest Worker</a> <a href="#ref-for-dfn-installing-worker-22">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-waiting-worker">
   <b><a href="#dfn-waiting-worker">#dfn-waiting-worker</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-waiting-worker-1">2.2. Service Worker Registration</a>
    <li><a href="#ref-for-dfn-waiting-worker-2">2.6. User Agent Shutdown</a>
    <li><a href="#ref-for-dfn-waiting-worker-3">4.1.3. skipWaiting()</a>
    <li><a href="#ref-for-dfn-waiting-worker-4">4.4. ExtendableEvent</a> <a href="#ref-for-dfn-waiting-worker-5">(2)</a>
    <li><a href="#ref-for-dfn-waiting-worker-6">Install</a> <a href="#ref-for-dfn-waiting-worker-7">(2)</a> <a href="#ref-for-dfn-waiting-worker-8">(3)</a> <a href="#ref-for-dfn-waiting-worker-9">(4)</a> <a href="#ref-for-dfn-waiting-worker-10">(5)</a> <a href="#ref-for-dfn-waiting-worker-11">(6)</a>
    <li><a href="#ref-for-dfn-waiting-worker-12">Activate</a> <a href="#ref-for-dfn-waiting-worker-13">(2)</a>
    <li><a href="#ref-for-dfn-waiting-worker-14">Handle Service Worker Client Unload</a>
    <li><a href="#ref-for-dfn-waiting-worker-15">Handle User Agent Shutdown</a>
    <li><a href="#ref-for-dfn-waiting-worker-16">Clear Registration</a> <a href="#ref-for-dfn-waiting-worker-17">(2)</a>
    <li><a href="#ref-for-dfn-waiting-worker-18">Update Registration State</a> <a href="#ref-for-dfn-waiting-worker-19">(2)</a> <a href="#ref-for-dfn-waiting-worker-20">(3)</a>
    <li><a href="#ref-for-dfn-waiting-worker-21">Update Worker State</a>
    <li><a href="#ref-for-dfn-waiting-worker-22">Get Newest Worker</a> <a href="#ref-for-dfn-waiting-worker-23">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-active-worker">
   <b><a href="#dfn-active-worker">#dfn-active-worker</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-active-worker-1">2.2. Service Worker Registration</a> <a href="#ref-for-dfn-active-worker-2">(2)</a> <a href="#ref-for-dfn-active-worker-3">(3)</a> <a href="#ref-for-dfn-active-worker-4">(4)</a> <a href="#ref-for-dfn-active-worker-5">(5)</a> <a href="#ref-for-dfn-active-worker-6">(6)</a>
    <li><a href="#ref-for-dfn-active-worker-7">2.3. Service Worker Client</a>
    <li><a href="#ref-for-dfn-active-worker-8">2.4. Selection and Use</a> <a href="#ref-for-dfn-active-worker-9">(2)</a> <a href="#ref-for-dfn-active-worker-10">(3)</a>
    <li><a href="#ref-for-dfn-active-worker-11">2.6. User Agent Shutdown</a>
    <li><a href="#ref-for-dfn-active-worker-12">3.4.2. ready</a> <a href="#ref-for-dfn-active-worker-13">(2)</a> <a href="#ref-for-dfn-active-worker-14">(3)</a>
    <li><a href="#ref-for-dfn-active-worker-15">3.6. Events</a>
    <li><a href="#ref-for-dfn-active-worker-16">4.1.3. skipWaiting()</a>
    <li><a href="#ref-for-dfn-active-worker-17">4.3.4. claim()</a> <a href="#ref-for-dfn-active-worker-18">(2)</a> <a href="#ref-for-dfn-active-worker-19">(3)</a>
    <li><a href="#ref-for-dfn-active-worker-20">4.4. ExtendableEvent</a>
    <li><a href="#ref-for-dfn-active-worker-21">4.7. Events</a>
    <li><a href="#ref-for-dfn-active-worker-22">Activate</a> <a href="#ref-for-dfn-active-worker-23">(2)</a> <a href="#ref-for-dfn-active-worker-24">(3)</a> <a href="#ref-for-dfn-active-worker-25">(4)</a> <a href="#ref-for-dfn-active-worker-26">(5)</a> <a href="#ref-for-dfn-active-worker-27">(6)</a> <a href="#ref-for-dfn-active-worker-28">(7)</a>
    <li><a href="#ref-for-dfn-active-worker-29">Run Service Worker</a>
    <li><a href="#ref-for-dfn-active-worker-30">Handle Fetch</a> <a href="#ref-for-dfn-active-worker-31">(2)</a> <a href="#ref-for-dfn-active-worker-32">(3)</a>
    <li><a href="#ref-for-dfn-active-worker-33">Handle Functional Event</a> <a href="#ref-for-dfn-active-worker-34">(2)</a>
    <li><a href="#ref-for-dfn-active-worker-35">Clear Registration</a> <a href="#ref-for-dfn-active-worker-36">(2)</a>
    <li><a href="#ref-for-dfn-active-worker-37">Update Registration State</a> <a href="#ref-for-dfn-active-worker-38">(2)</a> <a href="#ref-for-dfn-active-worker-39">(3)</a>
    <li><a href="#ref-for-dfn-active-worker-40">Update Worker State</a> <a href="#ref-for-dfn-active-worker-41">(2)</a> <a href="#ref-for-dfn-active-worker-42">(3)</a>
    <li><a href="#ref-for-dfn-active-worker-43">Get Newest Worker</a> <a href="#ref-for-dfn-active-worker-44">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-last-update-check-time">
   <b><a href="#dfn-last-update-check-time">#dfn-last-update-check-time</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-last-update-check-time-1">Update</a> <a href="#ref-for-dfn-last-update-check-time-2">(2)</a> <a href="#ref-for-dfn-last-update-check-time-3">(3)</a>
    <li><a href="#ref-for-dfn-last-update-check-time-4">Handle Fetch</a> <a href="#ref-for-dfn-last-update-check-time-5">(2)</a> <a href="#ref-for-dfn-last-update-check-time-6">(3)</a>
    <li><a href="#ref-for-dfn-last-update-check-time-7">Handle Functional Event</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-uninstalling-flag">
   <b><a href="#dfn-uninstalling-flag">#dfn-uninstalling-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-uninstalling-flag-1">3.4.5. getRegistrations()</a>
    <li><a href="#ref-for-dfn-uninstalling-flag-2">Register</a>
    <li><a href="#ref-for-dfn-uninstalling-flag-3">Update</a>
    <li><a href="#ref-for-dfn-uninstalling-flag-4">Handle Service Worker Client Unload</a>
    <li><a href="#ref-for-dfn-uninstalling-flag-5">Unregister</a>
    <li><a href="#ref-for-dfn-uninstalling-flag-6">Match Service Worker Registration</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-registration-task-queue">
   <b><a href="#dfn-service-worker-registration-task-queue">#dfn-service-worker-registration-task-queue</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-registration-task-queue-1">2.2. Service Worker Registration</a> <a href="#ref-for-dfn-service-worker-registration-task-queue-2">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-registration-task-queue-3">Run Service Worker</a>
    <li><a href="#ref-for-dfn-service-worker-registration-task-queue-4">Terminate Service Worker</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-client">
   <b><a href="#dfn-service-worker-client">#dfn-service-worker-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-client-1">2.1. Service Worker</a>
    <li><a href="#ref-for-dfn-service-worker-client-2">2.1.1. Lifetime</a>
    <li><a href="#ref-for-dfn-service-worker-client-3">2.2.1. Lifetime</a>
    <li><a href="#ref-for-dfn-service-worker-client-4">2.3. Service Worker Client</a> <a href="#ref-for-dfn-service-worker-client-5">(2)</a> <a href="#ref-for-dfn-service-worker-client-6">(3)</a> <a href="#ref-for-dfn-service-worker-client-7">(4)</a> <a href="#ref-for-dfn-service-worker-client-8">(5)</a> <a href="#ref-for-dfn-service-worker-client-9">(6)</a>
    <li><a href="#ref-for-dfn-service-worker-client-10">2.4. Selection and Use</a> <a href="#ref-for-dfn-service-worker-client-11">(2)</a> <a href="#ref-for-dfn-service-worker-client-12">(3)</a> <a href="#ref-for-dfn-service-worker-client-13">(4)</a> <a href="#ref-for-dfn-service-worker-client-14">(5)</a> <a href="#ref-for-dfn-service-worker-client-15">(6)</a> <a href="#ref-for-dfn-service-worker-client-16">(7)</a> <a href="#ref-for-dfn-service-worker-client-17">(8)</a> <a href="#ref-for-dfn-service-worker-client-18">(9)</a>
    <li><a href="#ref-for-dfn-service-worker-client-19">3.2.6. unregister()</a> <a href="#ref-for-dfn-service-worker-client-20">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-client-21">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-dfn-service-worker-client-22">3.6. Events</a> <a href="#ref-for-dfn-service-worker-client-23">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-client-24">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-dfn-service-worker-client-25">4.2. Client</a>
    <li><a href="#ref-for-dfn-service-worker-client-26">4.3.1. get(id)</a>
    <li><a href="#ref-for-dfn-service-worker-client-27">4.3.2. matchAll(options)</a> <a href="#ref-for-dfn-service-worker-client-28">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-client-29">4.3.4. claim()</a>
    <li><a href="#ref-for-dfn-service-worker-client-30">4.6.2. event.origin</a>
    <li><a href="#ref-for-dfn-service-worker-client-31">6.1. Secure Context</a> <a href="#ref-for-dfn-service-worker-client-32">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-client-33">6.3.1. Origin restriction</a>
    <li><a href="#ref-for-dfn-service-worker-client-34">Appendix A: Algorithms</a>
    <li><a href="#ref-for-dfn-service-worker-client-35">Create Job</a>
    <li><a href="#ref-for-dfn-service-worker-client-36">Install</a> <a href="#ref-for-dfn-service-worker-client-37">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-client-38">Activate</a> <a href="#ref-for-dfn-service-worker-client-39">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-client-40">Run Service Worker</a>
    <li><a href="#ref-for-dfn-service-worker-client-41">Handle Fetch</a> <a href="#ref-for-dfn-service-worker-client-42">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-client-43">Handle Service Worker Client Unload</a> <a href="#ref-for-dfn-service-worker-client-44">(2)</a> <a href="#ref-for-dfn-service-worker-client-45">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-client-46">Unregister</a>
    <li><a href="#ref-for-dfn-service-worker-client-47">Notify Controller Change</a>
    <li><a href="#ref-for-dfn-service-worker-client-48">Create Client</a>
    <li><a href="#ref-for-dfn-service-worker-client-49">Create Window Client</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-client-active-worker">
   <b><a href="#dfn-service-worker-client-active-worker">#dfn-service-worker-client-active-worker</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-client-active-worker-1">3.2.6. unregister()</a>
    <li><a href="#ref-for-dfn-service-worker-client-active-worker-2">3.4.1. controller</a>
    <li><a href="#ref-for-dfn-service-worker-client-active-worker-3">3.6. Events</a>
    <li><a href="#ref-for-dfn-service-worker-client-active-worker-4">4.2.8. navigate(url)</a>
    <li><a href="#ref-for-dfn-service-worker-client-active-worker-5">4.3.2. matchAll(options)</a>
    <li><a href="#ref-for-dfn-service-worker-client-active-worker-6">Handle Fetch</a> <a href="#ref-for-dfn-service-worker-client-active-worker-7">(2)</a> <a href="#ref-for-dfn-service-worker-client-active-worker-8">(3)</a> <a href="#ref-for-dfn-service-worker-client-active-worker-9">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-client-id">
   <b><a href="#dfn-service-worker-client-id">#dfn-service-worker-client-id</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-client-id-1">4.2.3. id</a>
    <li><a href="#ref-for-dfn-service-worker-client-id-2">4.3.1. get(id)</a>
    <li><a href="#ref-for-dfn-service-worker-client-id-3">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-client-frame-type">
   <b><a href="#dfn-service-worker-client-frame-type">#dfn-service-worker-client-frame-type</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-client-frame-type-1">4.2.2. frameType</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-window-client">
   <b><a href="#dfn-window-client">#dfn-window-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-window-client-1">4.2.2. frameType</a> <a href="#ref-for-dfn-window-client-2">(2)</a> <a href="#ref-for-dfn-window-client-3">(3)</a>
    <li><a href="#ref-for-dfn-window-client-4">4.3.1. get(id)</a>
    <li><a href="#ref-for-dfn-window-client-5">4.3.2. matchAll(options)</a> <a href="#ref-for-dfn-window-client-6">(2)</a> <a href="#ref-for-dfn-window-client-7">(3)</a>
    <li><a href="#ref-for-dfn-window-client-8">Activate</a>
    <li><a href="#ref-for-dfn-window-client-9">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-dedicatedworker-client">
   <b><a href="#dfn-dedicatedworker-client">#dfn-dedicatedworker-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-dedicatedworker-client-1">2.3. Service Worker Client</a>
    <li><a href="#ref-for-dfn-dedicatedworker-client-2">4.3.2. matchAll(options)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-sharedworker-client">
   <b><a href="#dfn-sharedworker-client">#dfn-sharedworker-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-sharedworker-client-1">2.3. Service Worker Client</a>
    <li><a href="#ref-for-dfn-sharedworker-client-2">4.3.2. matchAll(options)</a>
    <li><a href="#ref-for-dfn-sharedworker-client-3">Activate</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-worker-client">
   <b><a href="#dfn-worker-client">#dfn-worker-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-worker-client-1">2.4. Selection and Use</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-registration-selection">
   <b><a href="#dfn-service-worker-registration-selection">#dfn-service-worker-registration-selection</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-registration-selection-1">2.4. Selection and Use</a> <a href="#ref-for-dfn-service-worker-registration-selection-2">(2)</a> <a href="#ref-for-dfn-service-worker-registration-selection-3">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-control">
   <b><a href="#dfn-control">#dfn-control</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-control-1">2.3. Service Worker Client</a>
    <li><a href="#ref-for-dfn-control-2">2.4. Selection and Use</a>
    <li><a href="#ref-for-dfn-control-3">3.2.6. unregister()</a>
    <li><a href="#ref-for-dfn-control-4">3.6. Events</a>
    <li><a href="#ref-for-dfn-control-5">Service Worker Script Response</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-use">
   <b><a href="#dfn-use">#dfn-use</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-use-1">2.4. Selection and Use</a>
    <li><a href="#ref-for-dfn-use-2">3.6. Events</a>
    <li><a href="#ref-for-dfn-use-3">4.1.3. skipWaiting()</a>
    <li><a href="#ref-for-dfn-use-4">Install</a>
    <li><a href="#ref-for-dfn-use-5">Activate</a>
    <li><a href="#ref-for-dfn-use-6">Handle Fetch</a>
    <li><a href="#ref-for-dfn-use-7">Handle Service Worker Client Unload</a> <a href="#ref-for-dfn-use-8">(2)</a>
    <li><a href="#ref-for-dfn-use-9">Unregister</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-handle-fetch-task-source">
   <b><a href="#dfn-handle-fetch-task-source">#dfn-handle-fetch-task-source</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-handle-fetch-task-source-1">2.2. Service Worker Registration</a>
    <li><a href="#ref-for-dfn-handle-fetch-task-source-2">Terminate Service Worker</a> <a href="#ref-for-dfn-handle-fetch-task-source-3">(2)</a>
    <li><a href="#ref-for-dfn-handle-fetch-task-source-4">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-handle-functional-event-task-source">
   <b><a href="#dfn-handle-functional-event-task-source">#dfn-handle-functional-event-task-source</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-handle-functional-event-task-source-1">2.2. Service Worker Registration</a>
    <li><a href="#ref-for-dfn-handle-functional-event-task-source-2">Terminate Service Worker</a> <a href="#ref-for-dfn-handle-functional-event-task-source-3">(2)</a>
    <li><a href="#ref-for-dfn-handle-functional-event-task-source-4">Handle Functional Event</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-interface">
   <b><a href="#service-worker-interface">#service-worker-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-interface-1">2.1.1. Lifetime</a>
    <li><a href="#ref-for-service-worker-interface-2">3.1. ServiceWorker</a> <a href="#ref-for-service-worker-interface-3">(2)</a> <a href="#ref-for-service-worker-interface-4">(3)</a> <a href="#ref-for-service-worker-interface-5">(4)</a> <a href="#ref-for-service-worker-interface-6">(5)</a> <a href="#ref-for-service-worker-interface-7">(6)</a>
    <li><a href="#ref-for-service-worker-interface-8">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-service-worker-interface-9">3.1.4. Event handler</a>
    <li><a href="#ref-for-service-worker-interface-10">3.2. ServiceWorkerRegistration</a> <a href="#ref-for-service-worker-interface-11">(2)</a> <a href="#ref-for-service-worker-interface-12">(3)</a>
    <li><a href="#ref-for-service-worker-interface-13">3.2.1. installing</a>
    <li><a href="#ref-for-service-worker-interface-14">3.2.2. waiting</a>
    <li><a href="#ref-for-service-worker-interface-15">3.2.3. active</a>
    <li><a href="#ref-for-service-worker-interface-16">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-interface-17">3.4.1. controller</a> <a href="#ref-for-service-worker-interface-18">(2)</a>
    <li><a href="#ref-for-service-worker-interface-19">3.5. ServiceWorkerMessageEvent</a> <a href="#ref-for-service-worker-interface-20">(2)</a> <a href="#ref-for-service-worker-interface-21">(3)</a>
    <li><a href="#ref-for-service-worker-interface-22">3.5.4. event.source</a>
    <li><a href="#ref-for-service-worker-interface-23">3.6. Events</a> <a href="#ref-for-service-worker-interface-24">(2)</a>
    <li><a href="#ref-for-service-worker-interface-25">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-service-worker-interface-26">4.2.4. postMessage(message, transfer)</a>
    <li><a href="#ref-for-service-worker-interface-27">4.6. ExtendableMessageEvent</a> <a href="#ref-for-service-worker-interface-28">(2)</a>
    <li><a href="#ref-for-service-worker-interface-29">Update Registration State</a> <a href="#ref-for-service-worker-interface-30">(2)</a> <a href="#ref-for-service-worker-interface-31">(3)</a>
    <li><a href="#ref-for-service-worker-interface-32">Update Worker State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-url-attribute">
   <b><a href="#service-worker-url-attribute">#service-worker-url-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-url-attribute-1">3.1. ServiceWorker</a>
    <li><a href="#ref-for-service-worker-url-attribute-2">3.1.1. scriptURL</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-state-attribute">
   <b><a href="#service-worker-state-attribute">#service-worker-state-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-state-attribute-1">3.1. ServiceWorker</a>
    <li><a href="#ref-for-service-worker-state-attribute-2">3.1.2. state</a>
    <li><a href="#ref-for-service-worker-state-attribute-3">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-service-worker-state-attribute-4">3.6. Events</a>
    <li><a href="#ref-for-service-worker-state-attribute-5">Update Worker State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-state-enum">
   <b><a href="#service-worker-state-enum">#service-worker-state-enum</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-state-enum-1">3.1. ServiceWorker</a> <a href="#ref-for-service-worker-state-enum-2">(2)</a> <a href="#ref-for-service-worker-state-enum-3">(3)</a>
    <li><a href="#ref-for-service-worker-state-enum-4">Update Worker State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-postmessage-method">
   <b><a href="#service-worker-postmessage-method">#service-worker-postmessage-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-postmessage-method-1">3.1. ServiceWorker</a>
    <li><a href="#ref-for-service-worker-postmessage-method-2">3.1.3. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-onstatechange-attribute">
   <b><a href="#service-worker-onstatechange-attribute">#service-worker-onstatechange-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-onstatechange-attribute-1">3.1. ServiceWorker</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-interface">
   <b><a href="#service-worker-registration-interface">#service-worker-registration-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-interface-1">2.2.1. Lifetime</a>
    <li><a href="#ref-for-service-worker-registration-interface-2">3.2. ServiceWorkerRegistration</a> <a href="#ref-for-service-worker-registration-interface-3">(2)</a> <a href="#ref-for-service-worker-registration-interface-4">(3)</a> <a href="#ref-for-service-worker-registration-interface-5">(4)</a>
    <li><a href="#ref-for-service-worker-registration-interface-6">3.2.7. Event handler</a>
    <li><a href="#ref-for-service-worker-registration-interface-7">3.4. ServiceWorkerContainer</a> <a href="#ref-for-service-worker-registration-interface-8">(2)</a> <a href="#ref-for-service-worker-registration-interface-9">(3)</a>
    <li><a href="#ref-for-service-worker-registration-interface-10">3.4.2. ready</a>
    <li><a href="#ref-for-service-worker-registration-interface-11">3.4.4. getRegistration(clientURL)</a>
    <li><a href="#ref-for-service-worker-registration-interface-12">3.4.5. getRegistrations()</a>
    <li><a href="#ref-for-service-worker-registration-interface-13">3.6. Events</a>
    <li><a href="#ref-for-service-worker-registration-interface-14">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-service-worker-registration-interface-15">4.1.2. registration</a>
    <li><a href="#ref-for-service-worker-registration-interface-16">8.1. Define API bound to Service Worker Registration</a>
    <li><a href="#ref-for-service-worker-registration-interface-17">Register</a>
    <li><a href="#ref-for-service-worker-registration-interface-18">Update</a>
    <li><a href="#ref-for-service-worker-registration-interface-19">Install</a> <a href="#ref-for-service-worker-registration-interface-20">(2)</a>
    <li><a href="#ref-for-service-worker-registration-interface-21">Update Registration State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-registration-interface-service-worker-registration">
   <b><a href="#dfn-service-worker-registration-interface-service-worker-registration">#dfn-service-worker-registration-interface-service-worker-registration</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-registration-interface-service-worker-registration-1">3.2.4. scope</a>
    <li><a href="#ref-for-dfn-service-worker-registration-interface-service-worker-registration-2">3.2.5. update()</a>
    <li><a href="#ref-for-dfn-service-worker-registration-interface-service-worker-registration-3">3.2.6. unregister()</a>
    <li><a href="#ref-for-dfn-service-worker-registration-interface-service-worker-registration-4">3.6. Events</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-installing-attribute">
   <b><a href="#service-worker-registration-installing-attribute">#service-worker-registration-installing-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-installing-attribute-1">3.2. ServiceWorkerRegistration</a>
    <li><a href="#ref-for-service-worker-registration-installing-attribute-2">3.2.1. installing</a>
    <li><a href="#ref-for-service-worker-registration-installing-attribute-3">Update Registration State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-waiting-attribute">
   <b><a href="#service-worker-registration-waiting-attribute">#service-worker-registration-waiting-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-waiting-attribute-1">3.2. ServiceWorkerRegistration</a>
    <li><a href="#ref-for-service-worker-registration-waiting-attribute-2">3.2.2. waiting</a>
    <li><a href="#ref-for-service-worker-registration-waiting-attribute-3">Update Registration State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-active-attribute">
   <b><a href="#service-worker-registration-active-attribute">#service-worker-registration-active-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-active-attribute-1">3.2. ServiceWorkerRegistration</a>
    <li><a href="#ref-for-service-worker-registration-active-attribute-2">3.2.3. active</a>
    <li><a href="#ref-for-service-worker-registration-active-attribute-3">Update Registration State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-scope-attribute">
   <b><a href="#service-worker-registration-scope-attribute">#service-worker-registration-scope-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-scope-attribute-1">3.2. ServiceWorkerRegistration</a>
    <li><a href="#ref-for-service-worker-registration-scope-attribute-2">3.2.4. scope</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-update-method">
   <b><a href="#service-worker-registration-update-method">#service-worker-registration-update-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-update-method-1">3.2. ServiceWorkerRegistration</a>
    <li><a href="#ref-for-service-worker-registration-update-method-2">3.2.5. update()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-unregister-method">
   <b><a href="#service-worker-registration-unregister-method">#service-worker-registration-unregister-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-unregister-method-1">3.2. ServiceWorkerRegistration</a>
    <li><a href="#ref-for-service-worker-registration-unregister-method-2">3.2.6. unregister()</a> <a href="#ref-for-service-worker-registration-unregister-method-3">(2)</a> <a href="#ref-for-service-worker-registration-unregister-method-4">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-onupdatefound-attribute">
   <b><a href="#service-worker-registration-onupdatefound-attribute">#service-worker-registration-onupdatefound-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-onupdatefound-attribute-1">3.2. ServiceWorkerRegistration</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="navigator-service-worker-attribute">
   <b><a href="#navigator-service-worker-attribute">#navigator-service-worker-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-navigator-service-worker-attribute-1">3.3. navigator.serviceWorker</a> <a href="#ref-for-navigator-service-worker-attribute-2">(2)</a> <a href="#ref-for-navigator-service-worker-attribute-3">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-serviceworkercontainer-registrationoptions">
   <b><a href="#dictdef-serviceworkercontainer-registrationoptions">#dictdef-serviceworkercontainer-registrationoptions</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-serviceworkercontainer-registrationoptions-1">3.4. ServiceWorkerContainer</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-registrationoptions-scope">
   <b><a href="#dom-registrationoptions-scope">#dom-registrationoptions-scope</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-registrationoptions-scope-1">3.4.3. register(scriptURL, options)</a> <a href="#ref-for-dom-registrationoptions-scope-2">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-interface">
   <b><a href="#service-worker-container-interface">#service-worker-container-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-interface-1">3.3. navigator.serviceWorker</a> <a href="#ref-for-service-worker-container-interface-2">(2)</a> <a href="#ref-for-service-worker-container-interface-3">(3)</a>
    <li><a href="#ref-for-service-worker-container-interface-4">3.4. ServiceWorkerContainer</a> <a href="#ref-for-service-worker-container-interface-5">(2)</a> <a href="#ref-for-service-worker-container-interface-6">(3)</a> <a href="#ref-for-service-worker-container-interface-7">(4)</a> <a href="#ref-for-service-worker-container-interface-8">(5)</a> <a href="#ref-for-service-worker-container-interface-9">(6)</a> <a href="#ref-for-service-worker-container-interface-10">(7)</a> <a href="#ref-for-service-worker-container-interface-11">(8)</a> <a href="#ref-for-service-worker-container-interface-12">(9)</a>
    <li><a href="#ref-for-service-worker-container-interface-13">3.4.7. Event handlers</a>
    <li><a href="#ref-for-service-worker-container-interface-14">3.6. Events</a>
    <li><a href="#ref-for-service-worker-container-interface-15">4.2.4. postMessage(message, transfer)</a>
    <li><a href="#ref-for-service-worker-container-interface-16">Notify Controller Change</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-container-interface-client">
   <b><a href="#dfn-service-worker-container-interface-client">#dfn-service-worker-container-interface-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-1">3.4.1. controller</a>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-2">3.4.2. ready</a>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-3">3.4.3. register(scriptURL, options)</a>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-4">3.4.4. getRegistration(clientURL)</a>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-5">3.4.5. getRegistrations()</a>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-6">3.6. Events</a>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-7">4.2.4. postMessage(message, transfer)</a>
    <li><a href="#ref-for-dfn-service-worker-container-interface-client-8">Notify Controller Change</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-ready-promise">
   <b><a href="#dfn-ready-promise">#dfn-ready-promise</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-ready-promise-1">3.4.2. ready</a> <a href="#ref-for-dfn-ready-promise-2">(2)</a> <a href="#ref-for-dfn-ready-promise-3">(3)</a> <a href="#ref-for-dfn-ready-promise-4">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-client-message-queue">
   <b><a href="#dfn-client-message-queue">#dfn-client-message-queue</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-client-message-queue-1">3.4. ServiceWorkerContainer</a> <a href="#ref-for-dfn-client-message-queue-2">(2)</a> <a href="#ref-for-dfn-client-message-queue-3">(3)</a>
    <li><a href="#ref-for-dfn-client-message-queue-4">3.4.6. startMessages()</a>
    <li><a href="#ref-for-dfn-client-message-queue-5">3.4.7. Event handlers</a>
    <li><a href="#ref-for-dfn-client-message-queue-6">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-controller-attribute">
   <b><a href="#service-worker-container-controller-attribute">#service-worker-container-controller-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-controller-attribute-1">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-container-controller-attribute-2">3.4.1. controller</a> <a href="#ref-for-service-worker-container-controller-attribute-3">(2)</a>
    <li><a href="#ref-for-service-worker-container-controller-attribute-4">3.6. Events</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-ready-attribute">
   <b><a href="#service-worker-container-ready-attribute">#service-worker-container-ready-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-ready-attribute-1">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-container-ready-attribute-2">3.4.2. ready</a> <a href="#ref-for-service-worker-container-ready-attribute-3">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-register-method">
   <b><a href="#service-worker-container-register-method">#service-worker-container-register-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-register-method-1">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-container-register-method-2">3.4.3. register(scriptURL, options)</a> <a href="#ref-for-service-worker-container-register-method-3">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-getregistration-method">
   <b><a href="#service-worker-container-getregistration-method">#service-worker-container-getregistration-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-getregistration-method-1">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-container-getregistration-method-2">3.4.4. getRegistration(clientURL)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-getregistrations-method">
   <b><a href="#service-worker-container-getregistrations-method">#service-worker-container-getregistrations-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-getregistrations-method-1">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-container-getregistrations-method-2">3.4.5. getRegistrations()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-startMessages-method">
   <b><a href="#service-worker-container-startMessages-method">#service-worker-container-startMessages-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-startMessages-method-1">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-container-startMessages-method-2">3.4.6. startMessages()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-oncontrollerchange-attribute">
   <b><a href="#service-worker-container-oncontrollerchange-attribute">#service-worker-container-oncontrollerchange-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-oncontrollerchange-attribute-1">3.4. ServiceWorkerContainer</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-onmessage-attribute">
   <b><a href="#service-worker-container-onmessage-attribute">#service-worker-container-onmessage-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-onmessage-attribute-1">3.4. ServiceWorkerContainer</a>
    <li><a href="#ref-for-service-worker-container-onmessage-attribute-2">3.4.7. Event handlers</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-serviceworkermessageevent-serviceworkermessageeventinit">
   <b><a href="#dictdef-serviceworkermessageevent-serviceworkermessageeventinit">#dictdef-serviceworkermessageevent-serviceworkermessageeventinit</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-serviceworkermessageevent-serviceworkermessageeventinit-1">3.5. ServiceWorkerMessageEvent</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="serviceworkermessage-event-interface">
   <b><a href="#serviceworkermessage-event-interface">#serviceworkermessage-event-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-serviceworkermessage-event-interface-1">3.5. ServiceWorkerMessageEvent</a> <a href="#ref-for-serviceworkermessage-event-interface-2">(2)</a>
    <li><a href="#ref-for-serviceworkermessage-event-interface-3">3.6. Events</a>
    <li><a href="#ref-for-serviceworkermessage-event-interface-4">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="serviceworkermessage-event-data-attribute">
   <b><a href="#serviceworkermessage-event-data-attribute">#serviceworkermessage-event-data-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-serviceworkermessage-event-data-attribute-1">3.5. ServiceWorkerMessageEvent</a>
    <li><a href="#ref-for-serviceworkermessage-event-data-attribute-2">3.5.1. event.data</a>
    <li><a href="#ref-for-serviceworkermessage-event-data-attribute-3">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="serviceworkermessage-event-origin-attribute">
   <b><a href="#serviceworkermessage-event-origin-attribute">#serviceworkermessage-event-origin-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-serviceworkermessage-event-origin-attribute-1">3.5. ServiceWorkerMessageEvent</a>
    <li><a href="#ref-for-serviceworkermessage-event-origin-attribute-2">3.5.2. event.origin</a>
    <li><a href="#ref-for-serviceworkermessage-event-origin-attribute-3">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="serviceworkermessage-event-lasteventid-attribute">
   <b><a href="#serviceworkermessage-event-lasteventid-attribute">#serviceworkermessage-event-lasteventid-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-serviceworkermessage-event-lasteventid-attribute-1">3.5. ServiceWorkerMessageEvent</a>
    <li><a href="#ref-for-serviceworkermessage-event-lasteventid-attribute-2">3.5.3. event.lastEventId</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="serviceworkermessage-event-source-attribute">
   <b><a href="#serviceworkermessage-event-source-attribute">#serviceworkermessage-event-source-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-serviceworkermessage-event-source-attribute-1">3.5. ServiceWorkerMessageEvent</a>
    <li><a href="#ref-for-serviceworkermessage-event-source-attribute-2">3.5.4. event.source</a>
    <li><a href="#ref-for-serviceworkermessage-event-source-attribute-3">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="serviceworkermessage-event-ports-attribute">
   <b><a href="#serviceworkermessage-event-ports-attribute">#serviceworkermessage-event-ports-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-serviceworkermessage-event-ports-attribute-1">3.5. ServiceWorkerMessageEvent</a>
    <li><a href="#ref-for-serviceworkermessage-event-ports-attribute-2">3.5.5. event.ports</a>
    <li><a href="#ref-for-serviceworkermessage-event-ports-attribute-3">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-statechange-event">
   <b><a href="#service-worker-statechange-event">#service-worker-statechange-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-statechange-event-1">3.1.4. Event handler</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-registration-updatefound-event">
   <b><a href="#service-worker-registration-updatefound-event">#service-worker-registration-updatefound-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-registration-updatefound-event-1">3.2.7. Event handler</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-controllerchange-event">
   <b><a href="#service-worker-container-controllerchange-event">#service-worker-container-controllerchange-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-controllerchange-event-1">3.4.7. Event handlers</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-container-message-event">
   <b><a href="#service-worker-container-message-event">#service-worker-container-message-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-container-message-event-1">3.4.7. Event handlers</a>
    <li><a href="#ref-for-service-worker-container-message-event-2">3.5. ServiceWorkerMessageEvent</a> <a href="#ref-for-service-worker-container-message-event-3">(2)</a>
    <li><a href="#ref-for-service-worker-container-message-event-4">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-interface">
   <b><a href="#service-worker-global-scope-interface">#service-worker-global-scope-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-interface-1">3.1.3. postMessage(message, transfer)</a> <a href="#ref-for-service-worker-global-scope-interface-2">(2)</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-3">3.2.5. update()</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-4">4.1. ServiceWorkerGlobalScope</a> <a href="#ref-for-service-worker-global-scope-interface-5">(2)</a> <a href="#ref-for-service-worker-global-scope-interface-6">(3)</a> <a href="#ref-for-service-worker-global-scope-interface-7">(4)</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-8">4.1.4. Event handlers</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-9">4.3. Clients</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-10">4.4. ExtendableEvent</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-11">4.7. Events</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-12">6.3.2. importScripts(urls)</a> <a href="#ref-for-service-worker-global-scope-interface-13">(2)</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-14">8.3. Define Event Handler</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-15">8.4. Request Functional Event Dispatch</a>
    <li><a href="#ref-for-service-worker-global-scope-interface-16">Run Service Worker</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-global-scope-service-worker">
   <b><a href="#dfn-service-worker-global-scope-service-worker">#dfn-service-worker-global-scope-service-worker</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-2">3.2.5. update()</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-3">4.1.2. registration</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-4">4.2.4. postMessage(message, transfer)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-5">4.2.8. navigate(url)</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-6">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-7">4.3.1. get(id)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-8">4.3.2. matchAll(options)</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-9">(2)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-10">4.3.3. openWindow(url)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-11">4.3.4. claim()</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-12">(2)</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-13">(3)</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-14">(4)</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-15">(5)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-16">4.7. Events</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-17">(2)</a> <a href="#ref-for-dfn-service-worker-global-scope-service-worker-18">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-19">6.3.2. importScripts(urls)</a>
    <li><a href="#ref-for-dfn-service-worker-global-scope-service-worker-20">Run Service Worker</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-clients-attribute">
   <b><a href="#service-worker-global-scope-clients-attribute">#service-worker-global-scope-clients-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-clients-attribute-1">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-service-worker-global-scope-clients-attribute-2">4.1.1. clients</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-scope-attribute">
   <b><a href="#service-worker-global-scope-scope-attribute">#service-worker-global-scope-scope-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-scope-attribute-1">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-service-worker-global-scope-scope-attribute-2">4.1.2. registration</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-skipwaiting-method">
   <b><a href="#service-worker-global-scope-skipwaiting-method">#service-worker-global-scope-skipwaiting-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-skipwaiting-method-1">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-service-worker-global-scope-skipwaiting-method-2">4.1.3. skipWaiting()</a> <a href="#ref-for-service-worker-global-scope-skipwaiting-method-3">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-oninstall-attribute">
   <b><a href="#service-worker-global-scope-oninstall-attribute">#service-worker-global-scope-oninstall-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-oninstall-attribute-1">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-service-worker-global-scope-oninstall-attribute-2">Update Worker State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-onactivate-attribute">
   <b><a href="#service-worker-global-scope-onactivate-attribute">#service-worker-global-scope-onactivate-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-onactivate-attribute-1">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-service-worker-global-scope-onactivate-attribute-2">Update Worker State</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-onfetch-attribute">
   <b><a href="#service-worker-global-scope-onfetch-attribute">#service-worker-global-scope-onfetch-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-onfetch-attribute-1">4.1. ServiceWorkerGlobalScope</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-onmessage-attribute">
   <b><a href="#service-worker-global-scope-onmessage-attribute">#service-worker-global-scope-onmessage-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-onmessage-attribute-1">4.1. ServiceWorkerGlobalScope</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-interface">
   <b><a href="#client-interface">#client-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-interface-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-client-interface-2">4.2. Client</a> <a href="#ref-for-client-interface-3">(2)</a> <a href="#ref-for-client-interface-4">(3)</a>
    <li><a href="#ref-for-client-interface-5">4.3. Clients</a>
    <li><a href="#ref-for-client-interface-6">4.6. ExtendableMessageEvent</a> <a href="#ref-for-client-interface-7">(2)</a>
    <li><a href="#ref-for-client-interface-8">4.6.4. event.source</a>
    <li><a href="#ref-for-client-interface-9">Create Client</a> <a href="#ref-for-client-interface-10">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-client-client">
   <b><a href="#dfn-service-worker-client-client">#dfn-service-worker-client-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-client-client-1">4.2.1. url</a>
    <li><a href="#ref-for-dfn-service-worker-client-client-2">4.2.2. frameType</a>
    <li><a href="#ref-for-dfn-service-worker-client-client-3">4.2.3. id</a>
    <li><a href="#ref-for-dfn-service-worker-client-client-4">4.2.4. postMessage(message, transfer)</a>
    <li><a href="#ref-for-dfn-service-worker-client-client-5">4.2.7. focus()</a> <a href="#ref-for-dfn-service-worker-client-client-6">(2)</a> <a href="#ref-for-dfn-service-worker-client-client-7">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-client-client-8">4.2.8. navigate(url)</a> <a href="#ref-for-dfn-service-worker-client-client-9">(2)</a> <a href="#ref-for-dfn-service-worker-client-client-10">(3)</a>
    <li><a href="#ref-for-dfn-service-worker-client-client-11">Create Client</a>
    <li><a href="#ref-for-dfn-service-worker-client-client-12">Create Window Client</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="window-client-interface">
   <b><a href="#window-client-interface">#window-client-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-window-client-interface-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-window-client-interface-2">4.2. Client</a> <a href="#ref-for-window-client-interface-3">(2)</a> <a href="#ref-for-window-client-interface-4">(3)</a> <a href="#ref-for-window-client-interface-5">(4)</a>
    <li><a href="#ref-for-window-client-interface-6">4.3. Clients</a>
    <li><a href="#ref-for-window-client-interface-7">Create Window Client</a> <a href="#ref-for-window-client-interface-8">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-client-visibilitystate">
   <b><a href="#dfn-service-worker-client-visibilitystate">#dfn-service-worker-client-visibilitystate</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-client-visibilitystate-1">4.2.5. visibilityState</a>
    <li><a href="#ref-for-dfn-service-worker-client-visibilitystate-2">Create Window Client</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-service-worker-client-focusstate">
   <b><a href="#dfn-service-worker-client-focusstate">#dfn-service-worker-client-focusstate</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-service-worker-client-focusstate-1">4.2.6. focused</a>
    <li><a href="#ref-for-dfn-service-worker-client-focusstate-2">4.2.7. focus()</a>
    <li><a href="#ref-for-dfn-service-worker-client-focusstate-3">Create Window Client</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-url-attribute">
   <b><a href="#client-url-attribute">#client-url-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-url-attribute-1">4.2. Client</a>
    <li><a href="#ref-for-client-url-attribute-2">4.2.1. url</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-frametype-attribute">
   <b><a href="#client-frametype-attribute">#client-frametype-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-frametype-attribute-1">4.2. Client</a>
    <li><a href="#ref-for-client-frametype-attribute-2">4.2.2. frameType</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="contextframetype-enum">
   <b><a href="#contextframetype-enum">#contextframetype-enum</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-contextframetype-enum-1">4.2. Client</a> <a href="#ref-for-contextframetype-enum-2">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-id-attribute">
   <b><a href="#client-id-attribute">#client-id-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-id-attribute-1">4.2. Client</a>
    <li><a href="#ref-for-client-id-attribute-2">4.2.3. id</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-postmessage-method">
   <b><a href="#client-postmessage-method">#client-postmessage-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-postmessage-method-1">4.2. Client</a>
    <li><a href="#ref-for-client-postmessage-method-2">4.2.4. postMessage(message, transfer)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-visibilitystate-attribute">
   <b><a href="#client-visibilitystate-attribute">#client-visibilitystate-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-visibilitystate-attribute-1">4.2. Client</a>
    <li><a href="#ref-for-client-visibilitystate-attribute-2">4.2.5. visibilityState</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-focused-attribute">
   <b><a href="#client-focused-attribute">#client-focused-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-focused-attribute-1">4.2. Client</a>
    <li><a href="#ref-for-client-focused-attribute-2">4.2.6. focused</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-focus-method">
   <b><a href="#client-focus-method">#client-focus-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-focus-method-1">4.2. Client</a>
    <li><a href="#ref-for-client-focus-method-2">4.2.7. focus()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="client-navigate-method">
   <b><a href="#client-navigate-method">#client-navigate-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-client-navigate-method-1">4.2. Client</a>
    <li><a href="#ref-for-client-navigate-method-2">4.2.8. navigate(url)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-clients-clientqueryoptions">
   <b><a href="#dictdef-clients-clientqueryoptions">#dictdef-clients-clientqueryoptions</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-clients-clientqueryoptions-1">4.3. Clients</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-clientqueryoptions-includeuncontrolled">
   <b><a href="#dom-clientqueryoptions-includeuncontrolled">#dom-clientqueryoptions-includeuncontrolled</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-clientqueryoptions-includeuncontrolled-1">4.3.2. matchAll(options)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-clientqueryoptions-type">
   <b><a href="#dom-clientqueryoptions-type">#dom-clientqueryoptions-type</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-clientqueryoptions-type-1">4.3.2. matchAll(options)</a> <a href="#ref-for-dom-clientqueryoptions-type-2">(2)</a> <a href="#ref-for-dom-clientqueryoptions-type-3">(3)</a> <a href="#ref-for-dom-clientqueryoptions-type-4">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="enumdef-clients-clienttype">
   <b><a href="#enumdef-clients-clienttype">#enumdef-clients-clienttype</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-enumdef-clients-clienttype-1">4.3. Clients</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="clients-interface">
   <b><a href="#clients-interface">#clients-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-clients-interface-1">4.1. ServiceWorkerGlobalScope</a>
    <li><a href="#ref-for-clients-interface-2">4.1.1. clients</a>
    <li><a href="#ref-for-clients-interface-3">4.3. Clients</a> <a href="#ref-for-clients-interface-4">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="clients-get-method">
   <b><a href="#clients-get-method">#clients-get-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-clients-get-method-1">4.3. Clients</a>
    <li><a href="#ref-for-clients-get-method-2">4.3.1. get(id)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="clients-matchall-method">
   <b><a href="#clients-matchall-method">#clients-matchall-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-clients-matchall-method-1">4.3. Clients</a>
    <li><a href="#ref-for-clients-matchall-method-2">4.3.2. matchAll(options)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="clients-openwindow-method">
   <b><a href="#clients-openwindow-method">#clients-openwindow-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-clients-openwindow-method-1">4.3. Clients</a>
    <li><a href="#ref-for-clients-openwindow-method-2">4.3.3. openWindow(url)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="clients-claim-method">
   <b><a href="#clients-claim-method">#clients-claim-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-clients-claim-method-1">4.3. Clients</a>
    <li><a href="#ref-for-clients-claim-method-2">4.3.4. claim()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-extendableeventinit">
   <b><a href="#dictdef-extendableeventinit">#dictdef-extendableeventinit</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-extendableeventinit-1">4.4. ExtendableEvent</a>
    <li><a href="#ref-for-dictdef-extendableeventinit-2">4.5. FetchEvent</a>
    <li><a href="#ref-for-dictdef-extendableeventinit-3">4.6. ExtendableMessageEvent</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendable-event-interface">
   <b><a href="#extendable-event-interface">#extendable-event-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendable-event-interface-1">4.4. ExtendableEvent</a> <a href="#ref-for-extendable-event-interface-2">(2)</a> <a href="#ref-for-extendable-event-interface-3">(3)</a> <a href="#ref-for-extendable-event-interface-4">(4)</a> <a href="#ref-for-extendable-event-interface-5">(5)</a> <a href="#ref-for-extendable-event-interface-6">(6)</a>
    <li><a href="#ref-for-extendable-event-interface-7">4.5. FetchEvent</a> <a href="#ref-for-extendable-event-interface-8">(2)</a>
    <li><a href="#ref-for-extendable-event-interface-9">4.6. ExtendableMessageEvent</a> <a href="#ref-for-extendable-event-interface-10">(2)</a>
    <li><a href="#ref-for-extendable-event-interface-11">4.7. Events</a> <a href="#ref-for-extendable-event-interface-12">(2)</a>
    <li><a href="#ref-for-extendable-event-interface-13">8.2. Define Functional Event</a>
    <li><a href="#ref-for-extendable-event-interface-14">Install</a>
    <li><a href="#ref-for-extendable-event-interface-15">Activate</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-extend-lifetime-promises">
   <b><a href="#dfn-extend-lifetime-promises">#dfn-extend-lifetime-promises</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-extend-lifetime-promises-1">4.4. ExtendableEvent</a> <a href="#ref-for-dfn-extend-lifetime-promises-2">(2)</a> <a href="#ref-for-dfn-extend-lifetime-promises-3">(3)</a> <a href="#ref-for-dfn-extend-lifetime-promises-4">(4)</a> <a href="#ref-for-dfn-extend-lifetime-promises-5">(5)</a> <a href="#ref-for-dfn-extend-lifetime-promises-6">(6)</a> <a href="#ref-for-dfn-extend-lifetime-promises-7">(7)</a> <a href="#ref-for-dfn-extend-lifetime-promises-8">(8)</a> <a href="#ref-for-dfn-extend-lifetime-promises-9">(9)</a>
    <li><a href="#ref-for-dfn-extend-lifetime-promises-10">4.4.1. event.waitUntil(f)</a>
    <li><a href="#ref-for-dfn-extend-lifetime-promises-11">4.5.4. event.respondWith(r)</a>
    <li><a href="#ref-for-dfn-extend-lifetime-promises-12">Install</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extensions-allowed-flag">
   <b><a href="#extensions-allowed-flag">#extensions-allowed-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extensions-allowed-flag-1">4.4. ExtendableEvent</a> <a href="#ref-for-extensions-allowed-flag-2">(2)</a> <a href="#ref-for-extensions-allowed-flag-3">(3)</a>
    <li><a href="#ref-for-extensions-allowed-flag-4">4.4.1. event.waitUntil(f)</a>
    <li><a href="#ref-for-extensions-allowed-flag-5">Install</a>
    <li><a href="#ref-for-extensions-allowed-flag-6">Activate</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendable-event-waituntil-method">
   <b><a href="#extendable-event-waituntil-method">#extendable-event-waituntil-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendable-event-waituntil-method-1">4.4. ExtendableEvent</a>
    <li><a href="#ref-for-extendable-event-waituntil-method-2">4.4.1. event.waitUntil(f)</a> <a href="#ref-for-extendable-event-waituntil-method-3">(2)</a>
    <li><a href="#ref-for-extendable-event-waituntil-method-4">4.5.4. event.respondWith(r)</a>
    <li><a href="#ref-for-extendable-event-waituntil-method-5">4.6. ExtendableMessageEvent</a>
    <li><a href="#ref-for-extendable-event-waituntil-method-6">Update Worker State</a> <a href="#ref-for-extendable-event-waituntil-method-7">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-fetchevent-fetcheventinit">
   <b><a href="#dictdef-fetchevent-fetcheventinit">#dictdef-fetchevent-fetcheventinit</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-fetchevent-fetcheventinit-1">4.5. FetchEvent</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="fetch-event-interface">
   <b><a href="#fetch-event-interface">#fetch-event-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-fetch-event-interface-1">4.5. FetchEvent</a> <a href="#ref-for-fetch-event-interface-2">(2)</a> <a href="#ref-for-fetch-event-interface-3">(3)</a>
    <li><a href="#ref-for-fetch-event-interface-4">4.7. Events</a>
    <li><a href="#ref-for-fetch-event-interface-5">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="fetchevent-potential-response">
   <b><a href="#fetchevent-potential-response">#fetchevent-potential-response</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-fetchevent-potential-response-1">4.5.4. event.respondWith(r)</a>
    <li><a href="#ref-for-fetchevent-potential-response-2">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="wait-to-respond-flag">
   <b><a href="#wait-to-respond-flag">#wait-to-respond-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-wait-to-respond-flag-1">4.5.4. event.respondWith(r)</a> <a href="#ref-for-wait-to-respond-flag-2">(2)</a>
    <li><a href="#ref-for-wait-to-respond-flag-3">Handle Fetch</a> <a href="#ref-for-wait-to-respond-flag-4">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="respond-with-entered-flag">
   <b><a href="#respond-with-entered-flag">#respond-with-entered-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-respond-with-entered-flag-1">4.5.4. event.respondWith(r)</a> <a href="#ref-for-respond-with-entered-flag-2">(2)</a>
    <li><a href="#ref-for-respond-with-entered-flag-3">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="respond-with-error-flag">
   <b><a href="#respond-with-error-flag">#respond-with-error-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-respond-with-error-flag-1">4.5.4. event.respondWith(r)</a> <a href="#ref-for-respond-with-error-flag-2">(2)</a> <a href="#ref-for-respond-with-error-flag-3">(3)</a> <a href="#ref-for-respond-with-error-flag-4">(4)</a>
    <li><a href="#ref-for-respond-with-error-flag-5">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="fetch-event-request-attribute">
   <b><a href="#fetch-event-request-attribute">#fetch-event-request-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-fetch-event-request-attribute-1">4.5. FetchEvent</a>
    <li><a href="#ref-for-fetch-event-request-attribute-2">4.5.1. event.request</a>
    <li><a href="#ref-for-fetch-event-request-attribute-3">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="fetch-event-clientid-attribute">
   <b><a href="#fetch-event-clientid-attribute">#fetch-event-clientid-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-fetch-event-clientid-attribute-1">4.5. FetchEvent</a>
    <li><a href="#ref-for-fetch-event-clientid-attribute-2">4.5.2. event.clientId</a>
    <li><a href="#ref-for-fetch-event-clientid-attribute-3">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="fetch-event-isreload-attribute">
   <b><a href="#fetch-event-isreload-attribute">#fetch-event-isreload-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-fetch-event-isreload-attribute-1">4.5. FetchEvent</a>
    <li><a href="#ref-for-fetch-event-isreload-attribute-2">4.5.3. event.isReload</a>
    <li><a href="#ref-for-fetch-event-isreload-attribute-3">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="fetch-event-respondwith-method">
   <b><a href="#fetch-event-respondwith-method">#fetch-event-respondwith-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-fetch-event-respondwith-method-1">4.5. FetchEvent</a>
    <li><a href="#ref-for-fetch-event-respondwith-method-2">4.5.4. event.respondWith(r)</a> <a href="#ref-for-fetch-event-respondwith-method-3">(2)</a>
    <li><a href="#ref-for-fetch-event-respondwith-method-4">6.4. Cross-Origin Resources and CORS</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-extendablemessageevent-extendablemessageeventinit">
   <b><a href="#dictdef-extendablemessageevent-extendablemessageeventinit">#dictdef-extendablemessageevent-extendablemessageeventinit</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-extendablemessageevent-extendablemessageeventinit-1">4.6. ExtendableMessageEvent</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendablemessage-event-interface">
   <b><a href="#extendablemessage-event-interface">#extendablemessage-event-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendablemessage-event-interface-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-extendablemessage-event-interface-2">4.6. ExtendableMessageEvent</a> <a href="#ref-for-extendablemessage-event-interface-3">(2)</a>
    <li><a href="#ref-for-extendablemessage-event-interface-4">4.7. Events</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendablemessage-event-data-attribute">
   <b><a href="#extendablemessage-event-data-attribute">#extendablemessage-event-data-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendablemessage-event-data-attribute-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-extendablemessage-event-data-attribute-2">4.6. ExtendableMessageEvent</a>
    <li><a href="#ref-for-extendablemessage-event-data-attribute-3">4.6.1. event.data</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendablemessage-event-origin-attribute">
   <b><a href="#extendablemessage-event-origin-attribute">#extendablemessage-event-origin-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendablemessage-event-origin-attribute-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-extendablemessage-event-origin-attribute-2">4.6. ExtendableMessageEvent</a>
    <li><a href="#ref-for-extendablemessage-event-origin-attribute-3">4.6.2. event.origin</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendablemessage-event-lasteventid-attribute">
   <b><a href="#extendablemessage-event-lasteventid-attribute">#extendablemessage-event-lasteventid-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendablemessage-event-lasteventid-attribute-1">4.6. ExtendableMessageEvent</a>
    <li><a href="#ref-for-extendablemessage-event-lasteventid-attribute-2">4.6.3. event.lastEventId</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendablemessage-event-source-attribute">
   <b><a href="#extendablemessage-event-source-attribute">#extendablemessage-event-source-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendablemessage-event-source-attribute-1">3.1.3. postMessage(message, transfer)</a> <a href="#ref-for-extendablemessage-event-source-attribute-2">(2)</a>
    <li><a href="#ref-for-extendablemessage-event-source-attribute-3">4.6. ExtendableMessageEvent</a>
    <li><a href="#ref-for-extendablemessage-event-source-attribute-4">4.6.4. event.source</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="extendablemessage-event-ports-attribute">
   <b><a href="#extendablemessage-event-ports-attribute">#extendablemessage-event-ports-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-extendablemessage-event-ports-attribute-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-extendablemessage-event-ports-attribute-2">4.6. ExtendableMessageEvent</a>
    <li><a href="#ref-for-extendablemessage-event-ports-attribute-3">4.6.5. event.ports</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-install-event">
   <b><a href="#service-worker-global-scope-install-event">#service-worker-global-scope-install-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-install-event-1">2.1. Service Worker</a>
    <li><a href="#ref-for-service-worker-global-scope-install-event-2">4.1.4. Event handlers</a>
    <li><a href="#ref-for-service-worker-global-scope-install-event-3">4.4. ExtendableEvent</a> <a href="#ref-for-service-worker-global-scope-install-event-4">(2)</a> <a href="#ref-for-service-worker-global-scope-install-event-5">(3)</a>
    <li><a href="#ref-for-service-worker-global-scope-install-event-6">Install</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-activate-event">
   <b><a href="#service-worker-global-scope-activate-event">#service-worker-global-scope-activate-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-activate-event-1">2.1. Service Worker</a>
    <li><a href="#ref-for-service-worker-global-scope-activate-event-2">4.1.4. Event handlers</a>
    <li><a href="#ref-for-service-worker-global-scope-activate-event-3">4.4. ExtendableEvent</a> <a href="#ref-for-service-worker-global-scope-activate-event-4">(2)</a> <a href="#ref-for-service-worker-global-scope-activate-event-5">(3)</a>
    <li><a href="#ref-for-service-worker-global-scope-activate-event-6">Activate</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-fetch-event">
   <b><a href="#service-worker-global-scope-fetch-event">#service-worker-global-scope-fetch-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-fetch-event-1">2.1. Service Worker</a>
    <li><a href="#ref-for-service-worker-global-scope-fetch-event-2">2.5. Task Sources</a>
    <li><a href="#ref-for-service-worker-global-scope-fetch-event-3">4.1.4. Event handlers</a>
    <li><a href="#ref-for-service-worker-global-scope-fetch-event-4">4.5. FetchEvent</a> <a href="#ref-for-service-worker-global-scope-fetch-event-5">(2)</a>
    <li><a href="#ref-for-service-worker-global-scope-fetch-event-6">6.5. Implementer Concerns</a>
    <li><a href="#ref-for-service-worker-global-scope-fetch-event-7">Handle Fetch</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="service-worker-global-scope-message-event">
   <b><a href="#service-worker-global-scope-message-event">#service-worker-global-scope-message-event</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-service-worker-global-scope-message-event-1">3.1.3. postMessage(message, transfer)</a>
    <li><a href="#ref-for-service-worker-global-scope-message-event-2">4.1.4. Event handlers</a>
    <li><a href="#ref-for-service-worker-global-scope-message-event-3">4.6. ExtendableMessageEvent</a> <a href="#ref-for-service-worker-global-scope-message-event-4">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-fetching-record">
   <b><a href="#dfn-fetching-record">#dfn-fetching-record</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-fetching-record-1">5.1. Constructs</a> <a href="#ref-for-dfn-fetching-record-2">(2)</a> <a href="#ref-for-dfn-fetching-record-3">(3)</a>
    <li><a href="#ref-for-dfn-fetching-record-4">5.4.2. matchAll(request, options)</a> <a href="#ref-for-dfn-fetching-record-5">(2)</a>
    <li><a href="#ref-for-dfn-fetching-record-6">5.4.4. addAll(requests)</a> <a href="#ref-for-dfn-fetching-record-7">(2)</a>
    <li><a href="#ref-for-dfn-fetching-record-8">5.4.5. put(request, response)</a> <a href="#ref-for-dfn-fetching-record-9">(2)</a>
    <li><a href="#ref-for-dfn-fetching-record-10">5.4.7. keys(request, options)</a>
    <li><a href="#ref-for-dfn-fetching-record-11">Query Cache</a>
    <li><a href="#ref-for-dfn-fetching-record-12">Batch Cache Operations</a> <a href="#ref-for-dfn-fetching-record-13">(2)</a> <a href="#ref-for-dfn-fetching-record-14">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-incumbent-record">
   <b><a href="#dfn-incumbent-record">#dfn-incumbent-record</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-incumbent-record-1">5.4.2. matchAll(request, options)</a>
    <li><a href="#ref-for-dfn-incumbent-record-2">5.4.4. addAll(requests)</a> <a href="#ref-for-dfn-incumbent-record-3">(2)</a>
    <li><a href="#ref-for-dfn-incumbent-record-4">5.4.5. put(request, response)</a> <a href="#ref-for-dfn-incumbent-record-5">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-request-to-response-map">
   <b><a href="#dfn-request-to-response-map">#dfn-request-to-response-map</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-request-to-response-map-1">5.4. Cache</a> <a href="#ref-for-dfn-request-to-response-map-2">(2)</a>
    <li><a href="#ref-for-dfn-request-to-response-map-3">5.4.2. matchAll(request, options)</a> <a href="#ref-for-dfn-request-to-response-map-4">(2)</a>
    <li><a href="#ref-for-dfn-request-to-response-map-5">5.4.4. addAll(requests)</a> <a href="#ref-for-dfn-request-to-response-map-6">(2)</a> <a href="#ref-for-dfn-request-to-response-map-7">(3)</a> <a href="#ref-for-dfn-request-to-response-map-8">(4)</a> <a href="#ref-for-dfn-request-to-response-map-9">(5)</a>
    <li><a href="#ref-for-dfn-request-to-response-map-10">5.4.5. put(request, response)</a> <a href="#ref-for-dfn-request-to-response-map-11">(2)</a> <a href="#ref-for-dfn-request-to-response-map-12">(3)</a> <a href="#ref-for-dfn-request-to-response-map-13">(4)</a> <a href="#ref-for-dfn-request-to-response-map-14">(5)</a>
    <li><a href="#ref-for-dfn-request-to-response-map-15">5.4.7. keys(request, options)</a>
    <li><a href="#ref-for-dfn-request-to-response-map-16">6.6. Privacy</a>
    <li><a href="#ref-for-dfn-request-to-response-map-17">Query Cache</a>
    <li><a href="#ref-for-dfn-request-to-response-map-18">Batch Cache Operations</a> <a href="#ref-for-dfn-request-to-response-map-19">(2)</a> <a href="#ref-for-dfn-request-to-response-map-20">(3)</a> <a href="#ref-for-dfn-request-to-response-map-21">(4)</a> <a href="#ref-for-dfn-request-to-response-map-22">(5)</a> <a href="#ref-for-dfn-request-to-response-map-23">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-name-to-cache-map">
   <b><a href="#dfn-name-to-cache-map">#dfn-name-to-cache-map</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-name-to-cache-map-1">5.1. Constructs</a>
    <li><a href="#ref-for-dfn-name-to-cache-map-2">5.5. CacheStorage</a> <a href="#ref-for-dfn-name-to-cache-map-3">(2)</a>
    <li><a href="#ref-for-dfn-name-to-cache-map-4">5.5.1. match(request, options)</a> <a href="#ref-for-dfn-name-to-cache-map-5">(2)</a>
    <li><a href="#ref-for-dfn-name-to-cache-map-6">5.5.2. has(cacheName)</a>
    <li><a href="#ref-for-dfn-name-to-cache-map-7">5.5.3. open(cacheName)</a> <a href="#ref-for-dfn-name-to-cache-map-8">(2)</a>
    <li><a href="#ref-for-dfn-name-to-cache-map-9">5.5.4. delete(cacheName)</a>
    <li><a href="#ref-for-dfn-name-to-cache-map-10">5.5.5. keys()</a>
    <li><a href="#ref-for-dfn-name-to-cache-map-11">6.6. Privacy</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="global-caches-attribute">
   <b><a href="#global-caches-attribute">#global-caches-attribute</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-global-caches-attribute-1">5.3. self.caches</a> <a href="#ref-for-global-caches-attribute-2">(2)</a>
    <li><a href="#ref-for-global-caches-attribute-3">5.3.1. caches</a>
    <li><a href="#ref-for-global-caches-attribute-4">5.4. Cache</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-cache-cachequeryoptions">
   <b><a href="#dictdef-cache-cachequeryoptions">#dictdef-cache-cachequeryoptions</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-cache-cachequeryoptions-1">5.4. Cache</a> <a href="#ref-for-dictdef-cache-cachequeryoptions-2">(2)</a> <a href="#ref-for-dictdef-cache-cachequeryoptions-3">(3)</a> <a href="#ref-for-dictdef-cache-cachequeryoptions-4">(4)</a> <a href="#ref-for-dictdef-cache-cachequeryoptions-5">(5)</a>
    <li><a href="#ref-for-dictdef-cache-cachequeryoptions-6">5.5. CacheStorage</a>
    <li><a href="#ref-for-dictdef-cache-cachequeryoptions-7">Query Cache</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachequeryoptions-ignoresearch">
   <b><a href="#dom-cachequeryoptions-ignoresearch">#dom-cachequeryoptions-ignoresearch</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachequeryoptions-ignoresearch-1">Query Cache</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachequeryoptions-ignoremethod">
   <b><a href="#dom-cachequeryoptions-ignoremethod">#dom-cachequeryoptions-ignoremethod</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachequeryoptions-ignoremethod-1">Query Cache</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachequeryoptions-ignorevary">
   <b><a href="#dom-cachequeryoptions-ignorevary">#dom-cachequeryoptions-ignorevary</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachequeryoptions-ignorevary-1">Query Cache</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachequeryoptions-cachename">
   <b><a href="#dom-cachequeryoptions-cachename">#dom-cachequeryoptions-cachename</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachequeryoptions-cachename-1">5.5.1. match(request, options)</a> <a href="#ref-for-dom-cachequeryoptions-cachename-2">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-cache-cachebatchoperation">
   <b><a href="#dictdef-cache-cachebatchoperation">#dictdef-cache-cachebatchoperation</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-cache-cachebatchoperation-1">5.4.4. addAll(requests)</a>
    <li><a href="#ref-for-dictdef-cache-cachebatchoperation-2">5.4.5. put(request, response)</a>
    <li><a href="#ref-for-dictdef-cache-cachebatchoperation-3">5.4.6. delete(request, options)</a>
    <li><a href="#ref-for-dictdef-cache-cachebatchoperation-4">Batch Cache Operations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachebatchoperation-type">
   <b><a href="#dom-cachebatchoperation-type">#dom-cachebatchoperation-type</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachebatchoperation-type-1">5.4.4. addAll(requests)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-type-2">5.4.5. put(request, response)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-type-3">5.4.6. delete(request, options)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-type-4">Batch Cache Operations</a> <a href="#ref-for-dom-cachebatchoperation-type-5">(2)</a> <a href="#ref-for-dom-cachebatchoperation-type-6">(3)</a> <a href="#ref-for-dom-cachebatchoperation-type-7">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachebatchoperation-request">
   <b><a href="#dom-cachebatchoperation-request">#dom-cachebatchoperation-request</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachebatchoperation-request-1">5.4.4. addAll(requests)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-request-2">5.4.5. put(request, response)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-request-3">5.4.6. delete(request, options)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-request-4">Batch Cache Operations</a> <a href="#ref-for-dom-cachebatchoperation-request-5">(2)</a> <a href="#ref-for-dom-cachebatchoperation-request-6">(3)</a> <a href="#ref-for-dom-cachebatchoperation-request-7">(4)</a> <a href="#ref-for-dom-cachebatchoperation-request-8">(5)</a> <a href="#ref-for-dom-cachebatchoperation-request-9">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachebatchoperation-response">
   <b><a href="#dom-cachebatchoperation-response">#dom-cachebatchoperation-response</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachebatchoperation-response-1">5.4.4. addAll(requests)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-response-2">5.4.5. put(request, response)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-response-3">Batch Cache Operations</a> <a href="#ref-for-dom-cachebatchoperation-response-4">(2)</a> <a href="#ref-for-dom-cachebatchoperation-response-5">(3)</a> <a href="#ref-for-dom-cachebatchoperation-response-6">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-cachebatchoperation-options">
   <b><a href="#dom-cachebatchoperation-options">#dom-cachebatchoperation-options</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-cachebatchoperation-options-1">5.4.6. delete(request, options)</a>
    <li><a href="#ref-for-dom-cachebatchoperation-options-2">Batch Cache Operations</a> <a href="#ref-for-dom-cachebatchoperation-options-3">(2)</a> <a href="#ref-for-dom-cachebatchoperation-options-4">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-interface">
   <b><a href="#cache-interface">#cache-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-interface-1">4.7. Events</a>
    <li><a href="#ref-for-cache-interface-2">5. Caches</a> <a href="#ref-for-cache-interface-3">(2)</a>
    <li><a href="#ref-for-cache-interface-4">5.1. Constructs</a> <a href="#ref-for-cache-interface-5">(2)</a>
    <li><a href="#ref-for-cache-interface-6">5.2. Understanding Cache Lifetimes</a> <a href="#ref-for-cache-interface-7">(2)</a> <a href="#ref-for-cache-interface-8">(3)</a> <a href="#ref-for-cache-interface-9">(4)</a> <a href="#ref-for-cache-interface-10">(5)</a>
    <li><a href="#ref-for-cache-interface-11">5.4. Cache</a> <a href="#ref-for-cache-interface-12">(2)</a> <a href="#ref-for-cache-interface-13">(3)</a> <a href="#ref-for-cache-interface-14">(4)</a>
    <li><a href="#ref-for-cache-interface-15">5.5. CacheStorage</a>
    <li><a href="#ref-for-cache-interface-16">5.5.1. match(request, options)</a> <a href="#ref-for-cache-interface-17">(2)</a>
    <li><a href="#ref-for-cache-interface-18">5.5.3. open(cacheName)</a> <a href="#ref-for-cache-interface-19">(2)</a>
    <li><a href="#ref-for-cache-interface-20">6.4. Cross-Origin Resources and CORS</a> <a href="#ref-for-cache-interface-21">(2)</a> <a href="#ref-for-cache-interface-22">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-match-method">
   <b><a href="#cache-match-method">#cache-match-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-match-method-1">5.4. Cache</a>
    <li><a href="#ref-for-cache-match-method-2">5.4.1. match(request, options)</a>
    <li><a href="#ref-for-cache-match-method-3">5.5.1. match(request, options)</a> <a href="#ref-for-cache-match-method-4">(2)</a> <a href="#ref-for-cache-match-method-5">(3)</a> <a href="#ref-for-cache-match-method-6">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-matchall-method">
   <b><a href="#cache-matchall-method">#cache-matchall-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-matchall-method-1">5.4. Cache</a>
    <li><a href="#ref-for-cache-matchall-method-2">5.4.1. match(request, options)</a>
    <li><a href="#ref-for-cache-matchall-method-3">5.4.2. matchAll(request, options)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-add-method">
   <b><a href="#cache-add-method">#cache-add-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-add-method-1">5.4. Cache</a>
    <li><a href="#ref-for-cache-add-method-2">5.4.3. add(request)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-addAll-method">
   <b><a href="#cache-addAll-method">#cache-addAll-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-addAll-method-1">5.4. Cache</a>
    <li><a href="#ref-for-cache-addAll-method-2">5.4.3. add(request)</a>
    <li><a href="#ref-for-cache-addAll-method-3">5.4.4. addAll(requests)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-put-method">
   <b><a href="#cache-put-method">#cache-put-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-put-method-1">5.4. Cache</a>
    <li><a href="#ref-for-cache-put-method-2">5.4.5. put(request, response)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-delete-method">
   <b><a href="#cache-delete-method">#cache-delete-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-delete-method-1">5.4. Cache</a>
    <li><a href="#ref-for-cache-delete-method-2">5.4.6. delete(request, options)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-keys-method">
   <b><a href="#cache-keys-method">#cache-keys-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-keys-method-1">5.4. Cache</a>
    <li><a href="#ref-for-cache-keys-method-2">5.4.7. keys(request, options)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cachestorage-global-object">
   <b><a href="#cachestorage-global-object">#cachestorage-global-object</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cachestorage-global-object-1">5.5. CacheStorage</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-storage-interface">
   <b><a href="#cache-storage-interface">#cache-storage-interface</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-storage-interface-1">5.3. self.caches</a>
    <li><a href="#ref-for-cache-storage-interface-2">5.3.1. caches</a>
    <li><a href="#ref-for-cache-storage-interface-3">5.5. CacheStorage</a> <a href="#ref-for-cache-storage-interface-4">(2)</a> <a href="#ref-for-cache-storage-interface-5">(3)</a> <a href="#ref-for-cache-storage-interface-6">(4)</a> <a href="#ref-for-cache-storage-interface-7">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-storage-match-method">
   <b><a href="#cache-storage-match-method">#cache-storage-match-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-storage-match-method-1">5.5. CacheStorage</a>
    <li><a href="#ref-for-cache-storage-match-method-2">5.5.1. match(request, options)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-storage-has-method">
   <b><a href="#cache-storage-has-method">#cache-storage-has-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-storage-has-method-1">5.5. CacheStorage</a>
    <li><a href="#ref-for-cache-storage-has-method-2">5.5.2. has(cacheName)</a>
    <li><a href="#ref-for-cache-storage-has-method-3">5.5.4. delete(cacheName)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-storage-open-method">
   <b><a href="#cache-storage-open-method">#cache-storage-open-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-storage-open-method-1">5.5. CacheStorage</a>
    <li><a href="#ref-for-cache-storage-open-method-2">5.5.3. open(cacheName)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-storage-delete-method">
   <b><a href="#cache-storage-delete-method">#cache-storage-delete-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-storage-delete-method-1">5.5. CacheStorage</a>
    <li><a href="#ref-for-cache-storage-delete-method-2">5.5.4. delete(cacheName)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="cache-storage-keys-method">
   <b><a href="#cache-storage-keys-method">#cache-storage-keys-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-cache-storage-keys-method-1">5.5. CacheStorage</a>
    <li><a href="#ref-for-cache-storage-keys-method-2">5.5.5. keys()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="importscripts-method">
   <b><a href="#importscripts-method">#importscripts-method</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-importscripts-method-1">6.3.1. Origin restriction</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-scope-to-registration-map">
   <b><a href="#dfn-scope-to-registration-map">#dfn-scope-to-registration-map</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-scope-to-registration-map-1">2.2.1. Lifetime</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-2">2.4. Selection and Use</a> <a href="#ref-for-dfn-scope-to-registration-map-3">(2)</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-4">3.4.2. ready</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-5">3.4.5. getRegistrations()</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-6">6.6. Privacy</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-7">Handle Functional Event</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-8">Handle User Agent Shutdown</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-9">Set Registration</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-10">Clear Registration</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-11">Match Service Worker Registration</a>
    <li><a href="#ref-for-dfn-scope-to-registration-map-12">Get Registration</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job">
   <b><a href="#dfn-job">#dfn-job</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-1">Appendix A: Algorithms</a> <a href="#ref-for-dfn-job-2">(2)</a> <a href="#ref-for-dfn-job-3">(3)</a> <a href="#ref-for-dfn-job-4">(4)</a> <a href="#ref-for-dfn-job-5">(5)</a> <a href="#ref-for-dfn-job-6">(6)</a> <a href="#ref-for-dfn-job-7">(7)</a> <a href="#ref-for-dfn-job-8">(8)</a> <a href="#ref-for-dfn-job-9">(9)</a> <a href="#ref-for-dfn-job-10">(10)</a> <a href="#ref-for-dfn-job-11">(11)</a> <a href="#ref-for-dfn-job-12">(12)</a> <a href="#ref-for-dfn-job-13">(13)</a> <a href="#ref-for-dfn-job-14">(14)</a> <a href="#ref-for-dfn-job-15">(15)</a>
    <li><a href="#ref-for-dfn-job-16">Create Job</a> <a href="#ref-for-dfn-job-17">(2)</a>
    <li><a href="#ref-for-dfn-job-18">Schedule Job</a>
    <li><a href="#ref-for-dfn-job-19">Finish Job</a>
    <li><a href="#ref-for-dfn-job-20">Resolve Job Promise</a>
    <li><a href="#ref-for-dfn-job-21">Reject Job Promise</a>
    <li><a href="#ref-for-dfn-job-22">Register</a>
    <li><a href="#ref-for-dfn-job-23">Update</a>
    <li><a href="#ref-for-dfn-job-24">Install</a>
    <li><a href="#ref-for-dfn-job-25">Unregister</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-type">
   <b><a href="#dfn-job-type">#dfn-job-type</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-type-1">Appendix A: Algorithms</a>
    <li><a href="#ref-for-dfn-job-type-2">Create Job</a> <a href="#ref-for-dfn-job-type-3">(2)</a>
    <li><a href="#ref-for-dfn-job-type-4">Run Job</a> <a href="#ref-for-dfn-job-type-5">(2)</a> <a href="#ref-for-dfn-job-type-6">(3)</a>
    <li><a href="#ref-for-dfn-job-type-7">Update</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-scope-url">
   <b><a href="#dfn-job-scope-url">#dfn-job-scope-url</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-scope-url-1">Appendix A: Algorithms</a> <a href="#ref-for-dfn-job-scope-url-2">(2)</a> <a href="#ref-for-dfn-job-scope-url-3">(3)</a>
    <li><a href="#ref-for-dfn-job-scope-url-4">Create Job</a>
    <li><a href="#ref-for-dfn-job-scope-url-5">Register</a> <a href="#ref-for-dfn-job-scope-url-6">(2)</a> <a href="#ref-for-dfn-job-scope-url-7">(3)</a>
    <li><a href="#ref-for-dfn-job-scope-url-8">Update</a>
    <li><a href="#ref-for-dfn-job-scope-url-9">Unregister</a> <a href="#ref-for-dfn-job-scope-url-10">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-script-url">
   <b><a href="#dfn-job-script-url">#dfn-job-script-url</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-script-url-1">Appendix A: Algorithms</a>
    <li><a href="#ref-for-dfn-job-script-url-2">Create Job</a>
    <li><a href="#ref-for-dfn-job-script-url-3">Register</a> <a href="#ref-for-dfn-job-script-url-4">(2)</a> <a href="#ref-for-dfn-job-script-url-5">(3)</a>
    <li><a href="#ref-for-dfn-job-script-url-6">Update</a> <a href="#ref-for-dfn-job-script-url-7">(2)</a> <a href="#ref-for-dfn-job-script-url-8">(3)</a> <a href="#ref-for-dfn-job-script-url-9">(4)</a> <a href="#ref-for-dfn-job-script-url-10">(5)</a> <a href="#ref-for-dfn-job-script-url-11">(6)</a> <a href="#ref-for-dfn-job-script-url-12">(7)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-worker-type">
   <b><a href="#dfn-job-worker-type">#dfn-job-worker-type</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-worker-type-1">3.2.5. update()</a>
    <li><a href="#ref-for-dfn-job-worker-type-2">Update</a> <a href="#ref-for-dfn-job-worker-type-3">(2)</a>
    <li><a href="#ref-for-dfn-job-worker-type-4">Soft Update</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-client">
   <b><a href="#dfn-job-client">#dfn-job-client</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-client-1">Create Job</a>
    <li><a href="#ref-for-dfn-job-client-2">Resolve Job Promise</a> <a href="#ref-for-dfn-job-client-3">(2)</a> <a href="#ref-for-dfn-job-client-4">(3)</a> <a href="#ref-for-dfn-job-client-5">(4)</a>
    <li><a href="#ref-for-dfn-job-client-6">Reject Job Promise</a> <a href="#ref-for-dfn-job-client-7">(2)</a> <a href="#ref-for-dfn-job-client-8">(3)</a> <a href="#ref-for-dfn-job-client-9">(4)</a>
    <li><a href="#ref-for-dfn-job-client-10">Register</a> <a href="#ref-for-dfn-job-client-11">(2)</a>
    <li><a href="#ref-for-dfn-job-client-12">Update</a> <a href="#ref-for-dfn-job-client-13">(2)</a>
    <li><a href="#ref-for-dfn-job-client-14">Unregister</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-promise">
   <b><a href="#dfn-job-promise">#dfn-job-promise</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-promise-1">Create Job</a>
    <li><a href="#ref-for-dfn-job-promise-2">Schedule Job</a>
    <li><a href="#ref-for-dfn-job-promise-3">Resolve Job Promise</a> <a href="#ref-for-dfn-job-promise-4">(2)</a>
    <li><a href="#ref-for-dfn-job-promise-5">Reject Job Promise</a> <a href="#ref-for-dfn-job-promise-6">(2)</a>
    <li><a href="#ref-for-dfn-job-promise-7">Install</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-list-of-equivalent-jobs">
   <b><a href="#dfn-job-list-of-equivalent-jobs">#dfn-job-list-of-equivalent-jobs</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-list-of-equivalent-jobs-1">Schedule Job</a>
    <li><a href="#ref-for-dfn-job-list-of-equivalent-jobs-2">Resolve Job Promise</a>
    <li><a href="#ref-for-dfn-job-list-of-equivalent-jobs-3">Reject Job Promise</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-force-bypass-cache-flag">
   <b><a href="#dfn-job-force-bypass-cache-flag">#dfn-job-force-bypass-cache-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-force-bypass-cache-flag-1">Soft Update</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-equivalent">
   <b><a href="#dfn-job-equivalent">#dfn-job-equivalent</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-equivalent-1">Schedule Job</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dfn-job-queue">
   <b><a href="#dfn-job-queue">#dfn-job-queue</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-job-queue-1">Appendix A: Algorithms</a> <a href="#ref-for-dfn-job-queue-2">(2)</a> <a href="#ref-for-dfn-job-queue-3">(3)</a> <a href="#ref-for-dfn-job-queue-4">(4)</a> <a href="#ref-for-dfn-job-queue-5">(5)</a> <a href="#ref-for-dfn-job-queue-6">(6)</a>
    <li><a href="#ref-for-dfn-job-queue-7">Schedule Job</a> <a href="#ref-for-dfn-job-queue-8">(2)</a> <a href="#ref-for-dfn-job-queue-9">(3)</a> <a href="#ref-for-dfn-job-queue-10">(4)</a>
    <li><a href="#ref-for-dfn-job-queue-11">Run Job</a> <a href="#ref-for-dfn-job-queue-12">(2)</a>
    <li><a href="#ref-for-dfn-job-queue-13">Finish Job</a> <a href="#ref-for-dfn-job-queue-14">(2)</a> <a href="#ref-for-dfn-job-queue-15">(3)</a> <a href="#ref-for-dfn-job-queue-16">(4)</a>
   </ul>
  </aside>
<script>/* script-dfn-panel */

        document.body.addEventListener("click", function(e) {
            var queryAll = function(sel) { return [].slice.call(document.querySelectorAll(sel)); }
            // Find the dfn element or panel, if any, that was clicked on.
            var el = e.target;
            var target;
            var hitALink = false;
            while(el.parentElement) {
                if(el.tagName == "A") {
                    // Clicking on a link in a <dfn> shouldn't summon the panel
                    hitALink = true;
                }
                if(el.classList.contains("dfn-paneled")) {
                    target = "dfn";
                    break;
                }
                if(el.classList.contains("dfn-panel")) {
                    target = "dfn-panel";
                    break;
                }
                el = el.parentElement;
            }
            if(target != "dfn-panel") {
                // Turn off any currently "on" or "activated" panels.
                queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(function(el){
                    el.classList.remove("on");
                    el.classList.remove("activated");
                });
            }
            if(target == "dfn" && !hitALink) {
                // open the panel
                var dfnPanel = document.querySelector(".dfn-panel[data-for='" + el.id + "']");
                if(dfnPanel) {
                    console.log(dfnPanel);
                    dfnPanel.classList.add("on");
                    var rect = el.getBoundingClientRect();
                    dfnPanel.style.left = window.scrollX + rect.right + 5 + "px";
                    dfnPanel.style.top = window.scrollY + rect.top + "px";
                    var panelRect = dfnPanel.getBoundingClientRect();
                    var panelWidth = panelRect.right - panelRect.left;
                    if(panelRect.right > document.body.scrollWidth && (rect.left - (panelWidth + 5)) > 0) {
                        // Reposition, because the panel is overflowing
                        dfnPanel.style.left = window.scrollX + rect.left - (panelWidth + 5) + "px";
                    }
                } else {
                    console.log("Couldn't find .dfn-panel[data-for='" + el.id + "']");
                }
            } else if(target == "dfn-panel") {
                // Switch it to "activated" state, which pins it.
                el.classList.add("activated");
                el.style.left = null;
                el.style.top = null;
            }

        });
        </script>
